Mercurial > hg > octave-lyh > gnulib-hg
changeset 6248:ba937772eda4
Portability fix: readlink is not portable.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Mon, 19 Sep 2005 15:32:08 +0000 |
parents | 06bf58313e18 |
children | 564133adbd69 |
files | ChangeLog gnulib-tool |
diffstat | 2 files changed, 26 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-09-18 Bruno Haible <bruno@clisp.org> + + Portability fix. + * gnulib-tool (func_readlink): New function. + (func_ln_if_changed): Use it. + 2005-09-18 Bruno Haible <bruno@clisp.org> * gnulib-tool: Revise --dry-run implementation. Use variable $doit
--- a/gnulib-tool +++ b/gnulib-tool @@ -22,7 +22,7 @@ progname=$0 package=gnulib -cvsdatestamp='$Date: 2005-09-19 15:31:32 $' +cvsdatestamp='$Date: 2005-09-19 15:32:08 $' last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'` version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'` @@ -162,6 +162,23 @@ exit 1 } +# func_readlink SYMLINK +# outputs the target of the given symlink. +if (type -p readlink) > /dev/null 2>&1; then + func_readlink () + { + # Use the readlink program from GNU coreutils. + readlink "$1" + } +else + func_readlink () + { + # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p' + # would do the wrong link if the link target contains " -> ". + LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p' + } +fi + # func_ln_if_changed SRC DEST # Like ln -s, but avoids munging timestamps if the link is correct. func_ln_if_changed () @@ -169,7 +186,7 @@ if test $# -ne 2; then echo "usage: func_ln_if_changed SRC DEST" >&2 fi - if test -L "$2" && test "$1" = "`readlink "$2"`"; then + if test -L "$2" && test "$1" = "`func_readlink "$2"`"; then : else rm -f "$2" @@ -371,9 +388,7 @@ esac while test -h "$self_abspathname"; do # Resolve symbolic link. - sedexpr1='s, -> ,#%%#,' - sedexpr2='s,^.*#%%#\(.*\)$,\1,p' - linkval=`LC_ALL=C ls -l "$self_abspathname" | sed -e "$sedexpr1" | sed -n -e "$sedexpr2"` + linkval=`func_readlink "$self_abspathname"` test -n "$linkval" || break case "$linkval" in /* ) self_abspathname="$linkval" ;;