Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #30518

Re: Command line arguments

From Ken Brody <kenbrody@spamcop.net>
Newsgroups comp.lang.c
Subject Re: Command line arguments
Date 2013-01-22 15:25 -0500
Organization A noiseless patient Spider
Message-ID <kdmsj1$ugf$1@dont-email.me> (permalink)
References (2 earlier) <vuGHs.2122$%k.1283@fx11.fr7> <_1HHs.63$kp4.24@newsfe09.iad> <XkHHs.1971$k04.70@fx20.fr7> <6AHHs.22803$fh5.11839@newsfe26.iad> <kcnhf2$6lm$1@dont-email.me>

Show all headers | View raw


On 1/10/2013 6:05 PM, BruceS wrote:
> On 01/10/2013 03:49 PM, Lew Pitcher wrote:
[...]
>>>> It's part of the shell you are running - I'm guessing bash? You can use
>>>> the built-in set and turn it off:
>>>>
>>>> set -o noglob
[...]
> Lew beat me to it.  From a terminal (in Linux), type 'echo *', and it echos
> a list of the files in that directory.  Enclose in quotes (as suggested
> elsethread), and type 'echo "*"', and get a single asterix. If, as Greg
> suggested, I type 'set -o noglog', then type 'echo *', I get the single
> asterix.  The globbing is being done by the OS, before your program gets
> run.  Bart, I don't know if noglob works in all shells, but that sounds like
> your best bet for the Linux side, as you say using enclosing quotes isn't
> practical.

Just note that that will affect *everything* for that shell.  What happens 
when the user complains that he can no longer do things like "ls -l *.txt"?

>> Also note that, in most environments, the behaviour that you are asking for
>> is governed by well-known options /in that environment/. In POSIX/SUS
>> environments, globbing is done by the shell, and the facilities to disable
>> globbing are well known (set -o noglob, or even singlequoting the
>> argument).
>>
>> You are trying to address a human-factors problem ("how to know to turn off
>> globbing when using this program") with code; never a good idea.
>>
>> Here's the best advice:
>>
>> ** DOCUMENT THE REQUIREMENT IN THE OPERATING INSTRUCTIONS **
>>
>> Wasn't that simple?
>>
>> HTH
>
> Thanks, Lew.  I may never have a need for noglob, but I didn't know about it
> before.

Back to comp.lang.c | Previous | Next | Find similar | Unroll thread


Thread

Re: Command line arguments Ken Brody <kenbrody@spamcop.net> - 2013-01-22 15:25 -0500

csiph-web