[276] in Zephyr_Bugs
zctl: argument parsing wrong
daemon@ATHENA.MIT.EDU (Calvin Clark)
Tue May 28 16:39:43 1991
Date: Tue, 28 May 91 16:39:30 -0400
From: Calvin Clark <ckclark@ATHENA.MIT.EDU>
To: changes@ATHENA.MIT.EDU
Reply-To: ckclark@mit.edu
Cc: bug-zephyr@ATHENA.MIT.EDU, acevedo@ATHENA.MIT.EDU
What happens in zctl is this:
The command line arguments are combined into a single string, and then
that string is passed to ss_execute_line. One possible solution would
be to check each of the command line arguments to see if it contains a
space, and if it does, to then prepend and append " to that argument
before putting it in the string which is handed to ss_execute_line.
This is a fairly simple change which avoids have to rewrite the ss*
routines and at the same time allows standard behavior in parsing of
double-quoted command line arguments.
The following patch fixes the problem for zctl. Similar changes for
other programs should not be difficult.
-Calvin
*** /source/athena/athena.lib/zephyr/clients/zctl/zctl.c Mon May 27 14:52:32 1991
--- zctl.c Tue May 28 16:28:52 1991
***************
*** 111,118 ****
if (argc > 1) {
*ssline = '\0';
! for (i=1;i<argc;i++)
! (void) sprintf(ssline+strlen(ssline),"%s ",argv[i]);
ssline[strlen(ssline)-1] = '\0';
code = ss_execute_line(sci_idx,ssline);
if (code)
--- 111,122 ----
if (argc > 1) {
*ssline = '\0';
! for (i=1;i<argc;i++) {
! if (index(argv[i],' '))
! (void) sprintf(ssline+strlen(ssline),"\"%s\" ",argv[i]);
! else
! (void) sprintf(ssline+strlen(ssline),"%s ",argv[i]);
! }
ssline[strlen(ssline)-1] = '\0';
code = ss_execute_line(sci_idx,ssline);
if (code)
>> From: acevedo@ATHENA.MIT.EDU
>> Date: Thu, 14 Mar 91 14:20:01 EST
>> To: bugs@ATHENA.MIT.EDU
>> Subject: decmips 7.2R: zctl
>>
>> System name: hydrox-cookie
>> Type and version: KN01 7.2R
>> Display type: PM-MONO
>>
>> What were you trying to do?
>> Subscribe to an instance that has a space in the name.
>>
>> What's wrong:
>> zctl sub message "foo bar" \* doesn't work; I get "Usage: sub
>> class instance [*]".
>>
>> What should have happened:
>> It should work.
>>
>> Please describe any relevant documentation references:
>> I think the problem is that zctl is using it's interactive
>> parsing routine on command line arguments. Thus, it doesn't care
>> that it received the following five arguments: "zctl", "sub",
>> "foo bar", and "*"; it goes ahead and uses its parsing routine on
>> them. So, the "solution" is to do zctl sub message \"foo bar\"
>> \*, so that the parsing routine sees the double quotes around
>> "foo bar". This, however, is wrong. The original syntax should
>> work.