🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.bugs.sys5
Article #848

Quoted space (was: Re: compressdir bug?)

#848
From: Ian Donaldson
Date: Sat, 17 Sep 1988 07:11
44 lines
1291 bytes
From article <450@gt-ford.gtisqr.UUCP>, by stu@gtisqr.UUCP (Stu Donaldson):
> As I said, my solution was to create /bin/test.  Here is a copy,
> it is incredibly simple.
> 
> 	:
> 	# /bin/test
> 	if [ $* ]
> 	then
> 	  exit 0
> 	else
> 	  exit 1
> 	fi
> 
> As you can see, it relies on the test command implimented within
> the shell.  

Whilst it is functionally compatable with a real /bin/test most of the
time, it does fall down when quoted strings containing white space are passed 
as arguments.

eg:
	newtest "hello there" = "hello there"

But this is really a problem with $* breaking the arguments up.

From sh(1) man page, under the section on Quoting,

	"$*" is equivalent to "$1 $2 ..."
and     "$@" is equivalent to "$1" "$2" ...

So the script should really be:

	:
 	# /bin/test
 	if [ "$@" ]
 	then
 	  exit 0
 	else
 	  exit 1
 	fi

This version works much better.

Ian D
Technical Details
Message-ID: <864@yabbie.rmit.oz>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!munnari!bruce!goanna!yabbie!rcodi
References: <450@gt-ford.gtisqr.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!munnari!bruce!goanna!yabbie!rcodi
From: rcodi@yabbie.rmit.oz (Ian Donaldson)
Newsgroups: comp.bugs.sys5
Subject: Quoted space (was: Re: compressdir bug?)
Message-ID: <864@yabbie.rmit.oz>
Date: 17 Sep 88 07:11:22 GMT
References: <450@gt-ford.gtisqr.UUCP>
Organization: RMIT Comm & Elec Eng, Melbourne, Australia.
Lines: 44