🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by David Elliott Tue, 14 Nov 1989 21:08
Major bug in bash 1.04 handling of "$@"
#713
Author: David Elliott
Date: Tue, 14 Nov 1989 21:08
156 lines
2115 bytes
It appears that the construct

	"$@"

does not work correctly.  The correct interpretations are:

	$*	$1 $2 $3 $4 ...
	"$*"	"$1 $2 $3 $4 ..."
	$@	$1 $2 $3 $4 ...
	"$@"	"$1" "$2" "$3" "$4" ...

The following (long, sorry) typescript shows the problem:

Script started on Tue Nov 14 13:04:53 1989
icky 1>cat bt
#!/mnt/dce/Src/bash-1.04/bash

PATH=/bin:/usr/bin

main()
{
	echo "main got $# arguments:"
	echo 'quoted $@'
	for i in "$@"
	{
		echo -e "\t$i"
	}
	echo ""
	echo 'plain $@'
	for i in $@
	{
		echo -e "\t$i"
	}
	echo ""
	echo 'plain $*'
	for i in $*
	{
		echo -e "\t$i"
	}
	echo ""
	sub 1 "$@"
	sub 2 $@
	sub 3 $*
}

sub()
{
	echo "sub execution $1 got $# arguments"
	echo 'quoted $@'
	for i in "$@"
	{
		echo -e "\t$i"
	}
	echo ""
	echo 'plain $@'
	for i in $@
	{
		echo -e "\t$i"
	}
	echo ""
	echo 'plain $*'
	for i in $*
	{
		echo -e "\t$i"
	}
	echo ""
}

main a1 a2 a3 a4 a5
exit 0
icky 2>bt
main got 5 arguments:
quoted $@
	a1 a2 a3 a4 a5

plain $@
	a1
	a2
	a3
	a4
	a5

plain $*
	a1
	a2
	a3
	a4
	a5

sub execution 1 got 2 arguments
quoted $@
	1 a1 a2 a3 a4 a5

plain $@
	1
	a1
	a2
	a3
	a4
	a5

plain $*
	1
	a1
	a2
	a3
	a4
	a5

sub execution 2 got 6 arguments
quoted $@
	2 a1 a2 a3 a4 a5

plain $@
	2
	a1
	a2
	a3
	a4
	a5

plain $*
	2
	a1
	a2
	a3
	a4
	a5

sub execution 3 got 6 arguments
quoted $@
	3 a1 a2 a3 a4 a5

plain $@
	3
	a1
	a2
	a3
	a4
	a5

plain $*
	3
	a1
	a2
	a3
	a4
	a5

icky 3>
script done on Tue Nov 14 13:04:59 1989
-- 
David Elliott
dce@sony.com | ...!{uunet,mips}!sonyusa!dce
(408)944-4073
"You can lead a robot to water, but you can not make him compute."
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads