Re: Question - reading command line parms inside a script.
From: Chris F.A. Johnson (c.fa.johnson_at_rogers.com)
Date: 03/11/04
- Next message: Nick Landsberg: "Re: first 200 charactes of an EBCDIC file"
- Previous message: Nick Landsberg: "Re: Question - reading command line parms inside a script."
- In reply to: Nick Landsberg: "Re: Question - reading command line parms inside a script."
- Next in thread: Nick Landsberg: "Re: Question - reading command line parms inside a script."
- Reply: Nick Landsberg: "Re: Question - reading command line parms inside a script."
- Reply: Ken Andrews: "Re: Question - reading command line parms inside a script."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 11 Mar 2004 00:11:37 GMT
On Thu, 11 Mar 2004 at 00:05 GMT, Nick Landsberg wrote:
> Chris F.A. Johnson wrote:
>> On Wed, 10 Mar 2004 at 19:33 GMT, Ken Andrews wrote:
>> [snip]
>>
>>
>>>Inside the script, I need the following parms (or any possible
>>>permutation, sequence is variable):
>>>
>>>1) a
>>>2) b
>>>3) "C"
>>>4) -f="d"
>>>
>>>The nearest solution I've found is using a line like:
>>>
>>>y.y a b \"C\" -f=\"d\"
>>>
>>>but it's a suboptimal result as it requires modifying several hundred
>>>scripts. The objective is to use the original lines as written in the
>>>scripts, and build a new script that intercepts the given command and
>>>receives the command-line parms exactly as written.
>>
>>
>> Unless you quote the quotes, your program CANNOT see them. If you
>> have a program that expects to see them without having them
>> escaped, you need to fix that program, it's broken.
>>
>> If you have scripts that expect to pass quotes without escaping
>> them, they are broken and need to be fixed.
>>
>>
>
> Correct on point one. The shell (whatever shell) uses
> escapes to determine whether to interpret the argument
> as a shell directive or an argument to pass to the
> program. It strips off the escapes. An additional problem
> is that there is usually more than one form of escape.
>
> The following illustrates that:
>
> MyMachine% cat xxx
> echo $@
>
> MyMachine% sh xxx a "<" b
> a < b
>
> MyMachine% sh xxx a \< b
> a < b
>
> so any scheme to preserve the escapes would have to
> emulate the shell's escape processing and then
> put the original argument strings back the way
> they were.
>
> As to the second point. I believe the original poster
> has a need to somehow convert the scripts, thus needs
> the original strings as written, rather than the
> scripts being broken.
If he's converting scripts (i.e., reading the strings from a
file), then there's no need to do anything; the quotes will not be
stripped (unless he's using eval).
His problem is preserving them on the command line; that requires
escaping.
> This may be possible in awk (altho I'm not sure) but
> it almost seems like a c-program would have to be built
> to do the complete job.
Before we can diagnose the OP's problem any further, we need to
know more about what he's doing, and what the problem is exactly.
--
Chris F.A. Johnson http://cfaj.freeshell.org/shell
===================================================================
My code (if any) in this post is copyright 2004, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License
- Next message: Nick Landsberg: "Re: first 200 charactes of an EBCDIC file"
- Previous message: Nick Landsberg: "Re: Question - reading command line parms inside a script."
- In reply to: Nick Landsberg: "Re: Question - reading command line parms inside a script."
- Next in thread: Nick Landsberg: "Re: Question - reading command line parms inside a script."
- Reply: Nick Landsberg: "Re: Question - reading command line parms inside a script."
- Reply: Ken Andrews: "Re: Question - reading command line parms inside a script."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|