Date: Mon, 5 May 1997 10:27:06 +0200 (MET DST) From: Zahemszky Gabor <zgabor@CoDe.hu> To: freebsd-questions@freebsd.org (FreeBSD questions) Cc: wosch@apfel.de Subject: Re: test -f $shvar Message-ID: <199705050827.KAA00520@CoDe.hu> In-Reply-To: <p1irafobpsc.fsf@campa.panke.de> from Wolfram Schneider at "May 3, 97 04:20:35 pm"
next in thread | previous in thread | raw e-mail | index | archive | help
> Steve Howe <un_x@anchorage.net> writes: > > > anyone notice how "test -f $shvar" always results in "true"? > > The programmer must check if the variable `shvar' is > not empty. E.g.: > > test -n "$shvar" -a -f "$shvar" I don't know, why isn't it enough: test -f "$shvar" if the shvar is empty, the test is -f "", but (as I know) I cannot have a file with null-length name, so it will be false. Gabor -- #!/bin/ksh trap 'rm -f /tmp/$$.$$' EXIT HUP INT QUIT TERM&&print '21N16I25C25E30, 40M30E33E25T15U!'>/tmp/$$.$$&&IFS=' ABCDEFGHIJKLMNOPQRSTUVWXYZ '&&set -A X $(</tmp/$$.$$)&&IFS=' 0123456789 '&&set -A Y $(</tmp/$$.$$);IFS=' '&&set -- "${X[@]}"&&for i do [[ $i = ? ]]&&print $i&&continue;[[ $i = ??? ]]&&j=$i&&i=${i%?};typeset -i40 i=8#$i&&print -n ${i#???}&&[[ "$j" = ??? ]]&&print -n "${j#??} "&&unset j;typeset +i i;done;set -- "${Y[@]}"&&set -A X&&for i do [[ $i = , ]]&&i=2;[[ $i = ?? ]]||typeset -l i;set -A X "${X[@]}" $i&&typeset +l i;done&&set -- ${X[@]}&&print $*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199705050827.KAA00520>