[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Upgrade to potato impossible?



oye.  how about this.  it's pure bourne shell, not full of *#%$&@! evil
bashisms.  even works on solaris, irix, linux...  wrap it in a function
if you must.

job

#!/bin/sh

pwd="/bin/pwd"

if [ -h "${1}" ]; then
 # hmm, symbolic link, kinda messy
 # grab what the link points to, and reset $1
 # BUG - if ${1} has a space in it, this will fail.  
   set -- "`ls -l "${1}" | awk '{print $(NF)}'`"
fi

file=`basename "${1}"`


if [ -f "${1}" ]; then 
   cd `dirname "${1}"` 2> /dev/null || exit 2
   dir=`${pwd}`           # /bin/pwd returns absolute paths
   echo "${dir}/${file}"

elif [ -d "${1}" ]; then 
   cd "${1}" 2> /dev/null || exit 2
   dir=`${pwd}`
   echo "${dir}"
   exit 0

else                      # umm, something funny here, bail out
   exit 1
fi



Your message dated: Sat, 26 Feb 2000 01:00:45 EST
>
>readlink () {
>  # perl kludge until readlink(1) from tetex-bin is moved into an essential=
> package
>  # returns what symlink actually points to
>  perl -e '$l =3D shift; exit 1 unless -l $l; $r =3D readlink $l; exit 1 un=
>less $r; print "$r\n"' $1;
>}
>
>Not sure we want libc6 pre-depending on perl, though ( >>shudder<< ), so
>something written in pure sh might be the way to go.


Reply to: