Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 10 Oct 2010 17:23:03 -0700
From:      Devin Teske <dteske@vicor.com>
To:        Garance A Drosihn <drosih@rpi.edu>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: sysrc -- a sysctl(8)-like utility for managing /etc/rc.conf et. al.
Message-ID:  <4A1D95C2-10BB-43D1-99E0-A0D68D8836DC@vicor.com>
In-Reply-To: <4CB25198.4020209@rpi.edu>
References:  <1286397912.27308.40.camel@localhost.localdomain>	<AANLkTikoohMo5ng-RM3tctTH__P6cqhQpm=FPhSE9mMg@mail.gmail.com>	<51B4504F-5AA4-47C5-BF23-FA51DE5BC8C8@vicor.com>	<AANLkTim=BLkd229vdEst8U0ugpq3UsHPxjZZp2qaJxH-@mail.gmail.com>	<238E0B24-AA12-4684-9651-84DA665BE893@vicor.com>	<4CB14E2D.3070806@freebsd.org> <663E0B47-9318-4C75-BAEB-5C4F9EAFFDD1@vicor.com> <4CB25198.4020209@rpi.edu>

next in thread | previous in thread | raw e-mail | index | archive | help

On Oct 10, 2010, at 4:51 PM, Garance A Drosihn wrote:

> On 10/10/10 7:09 PM, Devin Teske wrote:=20
>> However, enclosing the argument (as the 'x$foo' portion is really =
just the first argument to the '[' built-in) in quotes:
>>=20
>> [ "$foo" =3D x ]
>>=20
>> makes it so that the expansion is taken as:
>>=20
>> [ "-n" =3D x ]
>>=20
>> rather than:
>>=20
>> [ -n =3D x ]
>>=20
>> The former not causing an error, while the latter does.
>>  =20
> The latter does not cause an error.  Try it:
>=20
> # [ "-n" =3D x ] ; echo $?
> 1
>=20
> # [ -e =3D "no" ] ; echo $?
> 1
>=20
> # [ -e =3D -n ] ; echo $?
> 1

Logical error, not functional error.


>> Quite functionally, at a C-level, if you have your array, ...
>>=20
>> argv[0] =3D "[\0";
>> argv[1] =3D "\"-n\"\0"; /* quoted syntax */
>> argv[2] =3D "=3D\0";
>> argv[3] =3D "x\0";
>>=20
>> and
>>=20
>> argv[0] =3D "[\0";
>> argv[1] =3D "-n\0"; /* non-quoted syntax */
>> argv[2] =3D "=3D\0";
>> argv[3] =3D "x\0";
>>=20
>>  =20
> You won't see the double-quotes in the C program.

Correct, an external C programming will get the arguments just like a =
shell script.


>   The shell processes single and double quotes, and passes the result =
to the C program which is running.  It might be different for built-in =
functions,

Indeed it is.


> but /bin/test would never see the double-quotes if they were used.  =
And since the built-in function has to work the same as standalone =
function

There is no distinction between "built-in function" and "standalone =
function". I think you mean "built-in" versus "external binary".

The way that parameters are passed off to the internal parser is =
different than the way arguments are passed to external executables.


> , I doubt the built-in would be any different.
>=20
> # list_args "-n" =20
>=20
> list_args at 19:36:15 Oct 10: $# =3D 1
>      ARG[000] l=3D002: '-n'
> # list_args -n
>=20
> list_args at 19:36:22 Oct 10: $# =3D 1
>      ARG[000] l=3D002: '-n'
>=20
> (note that the single-quotes you see there are printed by the =
list_args script itself for display purposes).
>=20
> disclaimer: I think this is the first post that I've made with the new =
"open-source edition" of Eudora, and I have no idea if this will be =
formatted the way I'm expecting it be!
>=20
> --=20
> Garance Alistair Drosehn     =3D              drosih@rpi.edu
> Senior Systems Programmer             or   gad@FreeBSD.org
> Rensselaer Polytechnic Institute;           Troy, NY;  USA
>=20

--
Cheers,
Devin Teske

-> CONTACT INFORMATION <-
Business Solutions Consultant II
FIS - fisglobal.com
510-735-5650 Mobile
510-621-2038 Office
510-621-2020 Office Fax
909-477-4578 Home/Fax
devin.teske@fisglobal.com

-> LEGAL DISCLAIMER <-
This message  contains confidential  and proprietary  information
of the sender,  and is intended only for the person(s) to whom it
is addressed. Any use, distribution, copying or disclosure by any
other person  is strictly prohibited.  If you have  received this
message in error,  please notify  the e-mail sender  immediately,
and delete the original message without making a copy.

-> FUN STUFF <-
-----BEGIN GEEK CODE BLOCK-----
Version 3.1
GAT/CS d(+) s: a- C++(++++) UB++++$ P++(++++) L++(++++) !E--- W++ N? o? =
K- w O
M+ V- PS+ PE Y+ PGP- t(+) 5? X+(++) R>++ tv(+) b+(++) DI+(++) D(+) G+>++ =
e>+ h
r>++ y+=20
------END GEEK CODE BLOCK------
http://www.geekcode.com/

-> END TRANSMISSION <-




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4A1D95C2-10BB-43D1-99E0-A0D68D8836DC>