Remove seq.in, in favor of the new function. Remove seq detection from configure.ac. Teach the Makefile how to remove old installed seqs.

This commit is contained in:
ridiculousfish 2013-01-12 15:18:19 -08:00
parent dc37a8079e
commit e1190eb1f3
3 changed files with 17 additions and 85 deletions

View file

@ -204,7 +204,7 @@ MAIN_DIR_FILES_UNSORTED := Doxyfile Doxyfile.user Doxyfile.help \
$(COMMON_FILES) $(COMMON_FILES:.cpp=.h) $(FISH_OBJS:.o=.cpp) \ $(COMMON_FILES) $(COMMON_FILES:.cpp=.h) $(FISH_OBJS:.o=.cpp) \
fish.spec.in INSTALL README user_doc.head.html xsel-0.9.6.tar \ fish.spec.in INSTALL README user_doc.head.html xsel-0.9.6.tar \
ChangeLog config.sub config.guess fish_tests.cpp fish.cpp fish_pager.cpp \ ChangeLog config.sub config.guess fish_tests.cpp fish.cpp fish_pager.cpp \
fishd.cpp seq.in make_vcs_completions.fish $(FISH_INDENT_OBJS:.o=.cpp) fishd.cpp make_vcs_completions.fish $(FISH_INDENT_OBJS:.o=.cpp)
# #
# The sorting is not meaningful in itself, but it has the side effect # The sorting is not meaningful in itself, but it has the side effect
@ -242,7 +242,7 @@ FUNCTIONS_DIR_FILES := $(wildcard share/functions/*.fish)
# #
SIMPLE_PROGRAMS := fish set_color mimedb fish_pager fishd fish_indent SIMPLE_PROGRAMS := fish set_color mimedb fish_pager fishd fish_indent
PROGRAMS := $(SIMPLE_PROGRAMS) @XSEL_BIN@ @SEQ_FALLBACK@ PROGRAMS := $(SIMPLE_PROGRAMS) @XSEL_BIN@
# #
@ -443,10 +443,10 @@ doc.h: $(HDR_FILES)
# Create a template translation object # Create a template translation object
# #
messages.pot: *.cpp *.h share/completions/*.fish share/functions/*.fish seq messages.pot: *.cpp *.h share/completions/*.fish share/functions/*.fish
if test $(HAVE_GETTEXT) = 1;then \ if test $(HAVE_GETTEXT) = 1;then \
xgettext -k_ -kN_ *.cpp *.h -o messages.pot; \ xgettext -k_ -kN_ *.cpp *.h -o messages.pot; \
if xgettext -j -k_ -kN_ -k--description -LShell share/completions/*.fish share/functions/*.fish seq -o messages.pot; then true; else \ if xgettext -j -k_ -kN_ -k--description -LShell share/completions/*.fish share/functions/*.fish -o messages.pot; then true; else \
echo "Your xgettext version is too old to build the messages.pot file"\ echo "Your xgettext version is too old to build the messages.pot file"\
rm messages.pot\ rm messages.pot\
false;\ false;\
@ -527,6 +527,17 @@ check-uninstall:
.PHONY: check-uninstall .PHONY: check-uninstall
# seq used to be a shell script that we would install
# Now we just look for previously installed seqs, and erase them
# No big deal if it fails
cleanup_old_seq:
SEQLOC=`which seq`;\
if test -x "$$SEQLOC" && grep -q '\(^#!/.*/fish\|^#!/usr/bin/env fish\)' "$$SEQLOC"; then\
rm -f "$$SEQLOC";\
fi;\
true;
.PHONY: cleanup_old_seq
# #
# This check makes sure that the install-sh script is executable. The # This check makes sure that the install-sh script is executable. The
# darcs repo doesn't preserve the executable bit, so this needs to be # darcs repo doesn't preserve the executable bit, so this needs to be
@ -542,7 +553,7 @@ install-sh:
# Try to install after checking for incompatible installed versions. # Try to install after checking for incompatible installed versions.
# #
install: all install-sh check-uninstall install-force install: all cleanup_old_seq install-sh check-uninstall install-force
.PHONY: install .PHONY: install
# #

View file

@ -34,7 +34,6 @@ AC_SUBST(LIBS_SET_COLOR)
AC_SUBST(localedir) AC_SUBST(localedir)
AC_SUBST(optbindirs) AC_SUBST(optbindirs)
AC_SUBST(prefix) AC_SUBST(prefix)
AC_SUBST(SEQ_FALLBACK)
AC_SUBST(XSEL) AC_SUBST(XSEL)
AC_SUBST(XSEL_MAN) AC_SUBST(XSEL_MAN)
AC_SUBST(XSEL_BIN) AC_SUBST(XSEL_BIN)
@ -167,37 +166,6 @@ AC_PROG_CXX([g++ c++])
AC_PROG_CPP AC_PROG_CPP
AC_PROG_INSTALL AC_PROG_INSTALL
#
# Check for seq command. If missing, make sure fallback shellscript
# implementation is installed.
#
AC_CHECK_PROG( SEQ_FALLBACK, seq, [ ], [seq])
if test "$SEQ_FALLBACK"; then
#
# We already have seq. Check if the seq version is installed by an
# earlier fish version. If it is, we'll replace it.
#
file=`which seq`
if test -f "$file"; then
AC_MSG_CHECKING([if seq comes from a previous fish version])
shebang=`grep "\(^#!/.*/fish\|^#!/usr/bin/env fish\)" $file`
if test "$shebang"; then
SEQ_FALLBACK=seq
AC_MSG_RESULT(yes, replace it)
else
AC_MSG_RESULT(no, keep it)
fi
fi
fi
# #
# Optionally drop xsel command # Optionally drop xsel command
# #
@ -950,7 +918,7 @@ case $target_os in
esac esac
# Tell the world what we know # Tell the world what we know
AC_CONFIG_FILES([Makefile fish.spec seq]) AC_CONFIG_FILES([Makefile fish.spec])
AC_OUTPUT AC_OUTPUT
if test ! x$local_found_posix_switch = xyes; then if test ! x$local_found_posix_switch = xyes; then

47
seq.in
View file

@ -1,47 +0,0 @@
# If seq is not installed, then define a function that invokes __fish_fallback_seq
if begin ; test -x /usr/bin/seq ; or type --no-functions seq > /dev/null; end
function seq --description "Print sequences of numbers"
__fish_fallback_seq $argv
end
end
function __fish_fallback_seq --description "Fallback implementation of the seq command"
set -l from 1
set -l step 1
set -l to 1
switch (count $argv)
case 1
set to $argv[1]
case 2
set from $argv[1]
set to $argv[2]
case 3
set from $argv[1]
set step $argv[2]
set to $argv[3]
case '*'
printf (_ "%s: Expected 1, 2 or 3 arguments, got %d\n") seq (count $argv)
exit 1
end
for i in $from $step $to
if not echo $i | grep -E '^-?[0-9]*([0-9]*|\.[0-9]+)$' >/dev/null
printf (_ "%s: '%s' is not a number\n") seq $i
exit 1
end
end
if [ $step -ge 0 ]
echo "for( i=$from; i<=$to ; i+=$step ) i;" | bc
else
echo "for( i=$from; i>=$to ; i+=$step ) i;" | bc
end
end