[Thread Prev][Thread Next][Index]

Re: [ferret_users] whitespace within command-line arguments



Hi Ryo, Russ,

The following syntax would also work, enclosing the argument that contains spaces in double quotes surrounded by single quotes. The arguments which don't contain spaces can be in quotes or not.

$ ferret -script tmp.jnl 'hello' '"a b c"' 'world'

When Ferret gets the arguments, they are strings which do not include surrounding quotes.  So for the original example,

$ /usr/local/ferret-7.3/bin/ferret_v7.3 -script tmp.jnl "hello" "a b c" "world"

What comes to Ferret is these arguments as strings but without any surrounding quotes.

hello
a b c
world

It uses these to in effect create the Ferret command

  go tmp.jnl hello a b c world

For my example with the second argument given as '"a b c"', it creates the command

  go tmp.jnl hello "a b c" world

And the example with backslashes acts similarly.

You'd think Ferret should just add quotes around the incoming arguments as they're put into that command line that's being created. I just fiddled with that a bit, but didn't get that to work consistently. And of course that would interfere with any quotes that the user has already sent in.

For the example

$ ferret -script tmp.jnl 'hello' '$3' 'world'

Ferret is of course running

   go tmp.jnl hello $3 world

where, interestingly enough, $3 is translated to argument 3 of the script, "world".  There does not seem to be a good way to escape that text.

On 12/19/2017 7:04 AM, Ryo Furue wrote:
Hi Russ,

Escaping with a backslash works for me with V7.1

ferret -script tmp.jnl "hello" "a\ b\ c" "world"
1st--hello--
2nd--a b c--
3rd--world-

Confirmed!  Thanks!

I'm curious. Why does Ferret process the parameters before assigning them to ($1), ($2), etc.?  (That must be the reason why the whitespaces must be escaped.)

For example,

$ ferret -script tmp.jnl 'hello' '$3' 'world'
1st--hello--
2nd--world--
3rd--world--
$

The second argument is replaced with the third!  (No, it's not the shell that does the substitution.)

This must be by design.  But how is this feature supposed to be used?

Cheers,

Ryo


[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement