Date: Wed, 23 Dec 2020 01:48:03 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 252061] sh does not pass $@ parameters properly Message-ID: <bug-252061-227@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D252061 Bug ID: 252061 Summary: sh does not pass $@ parameters properly Product: Base System Version: 11.4-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: jguojun@gmail.com When using $@ to pass parameter, sh supposed to pass every tuple as is. That is, passing "abc 123" to another sh script, "abc 123" should be intact= as one parameter. Currently, using $@ and $* to pass parameter from one sh script to another = does not make difference: all parameters are passed as single items. A simple testing script is appended below and save it to two files -- sh1 a= nd sh2. run sh1 with parameters "123 456" "abc def" xyz. The orignal parameter tuples are 3 shown in sh1 correctly. According to maunal, $@ should pass "123 456" "abc def" xyz as is (3 tuples= ). $* should pass "123 456" "abc def" xyz as 5 items as 123 456 abc def xyz However, both $@ and $* pass 5 parameters to the sh2. : ./sh1 "123 456" "abc def" xyz ./sh1 3 tuples 123 456 abc def xyz ./sh2 5 tuples 123 456 abc def xyz ./sh2 5 tuples 123 456 abc def xyz : cat sh1 #!/bin/sh echo echo $0 $# tuples n=3D1 while [ $n -le $# ]; do eval echo \$$n n=3D$((n+1)) done [ $0 =3D sh1 -o $0 =3D ./sh1 ] && ./sh2 $@ [ $0 =3D sh1 -o $0 =3D ./sh1 ] && ./sh2 $* --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-252061-227>