Subject: Re: sh script question
To: Gan Uesli Starling <oinkfreebiker@att.net>
From: Andreas Kahari <ak@sdf.freeshell.org>
List: netbsd-help
Date: 02/22/2002 09:46:17
That's not an error.

Some shells don't like the comparison

    if [ "" = "" ]

So to guard against that we prefix both sides with a random
letter ("x").  In case $PTY would be empty we get

    if [ "x" = "x" ]

... which is perfectly ok.



Andreas


On Wed, Feb 20, 2002 at 09:56:25AM -0500, Gan Uesli Starling wrote:
> Howdy,
> 
> Am researching my problem with ssh-ip-tunnel. Is NOT an ssh problem. I 
> found this curious item in the script /usr/pkg/sbin/vpn. See where it 
> says:  <clip> if [ "x$PTY" = "x" ] </clip> that does not look right to 
> me. I'm thinking maybe that little "x" in "x$PTY" does not belong? Does 
> it?  The package installed it that way.
> 
> vpn_start()
> {
>         PEER=$1
> 
>         PTY=`$REDIR $SSH -e none -t -o 'Batchmode yes' -i $RSAKEY  \    
>                    $SSHUSER  $PEER $REMOTEPPP $RPPPOPTIONS`
> 
>         echo "Issuing $REMOTEPPP $RPPPOPTIONS on $PTY"
> 
>         if [ "x$PTY" = "x" ]
>         then
>                 echo "Failed to get a pty"
>                 exit 1
>         fi
> 
>         $LOCALPPP $PTY $LOCALADDR:$REMOTEADDR $LPPPOPTIONS
> }
> 
> Thanks,
> 
> Gan

-- 
Andreas Kahari, Dunedin, New Zealand
--------------------------------------