Re: Can $1 be set in a script?



On Thu, 30 Mar 2006 23:15:35 -0900, floyd@xxxxxxxxxx (Floyd L.
Davidson) wrote:

larryalk <nobody@xxxxxxxxxxx> wrote:
On Fri, 31 Mar 2006 01:35:57 -0500, Bill Marcum <bmarcum@xxxxxxxxx>
wrote:

something=${1:-"default string"}

Excellent point.

Bill I ran across this exact same construction before in connection
with an ~/.xinitrc script.

Would you please tell me what the syntax means of:
(1:-"default string")

It does exactly the same thing that the several lines of my code
did.

I _guess_ it represents a variable.
What does the colon and minus sign signify?

Why guess... you should read the man page for bash...

Start by reading the section titled "Parameter Expansion".

Thank you Floyd. I had been thinking of how to use Google to get a
handle on that but man bash explained it all.

This {1:-string} construct is going to be very handy.

After re-thinking about my subject "Can $1 be set in a script?" I
realize that I just wasn't thinking. Apparently I made a big fuss
over nothing.

It's easy to create
1=something
2=borrowed

echo $1 $2
something borrowed

Voila, $1 and $2 created where they didn't exist before.
But {1:-string} is even better.

Larry

--
My real sig is much better.
.



Relevant Pages

  • Re: Script-fu scritp to add border with exif data
    ... I've just put on my web site a GIMP script written in ... Python that you might be interested in: ... It is the same basic script that I've been using for a ... "Copyright %Y Floyd L. Davidson, ...
    (comp.graphics.apps.gimp)
  • Re: Free Utility That Displays RAW Pixels?
    ... Floyd L. Davidson ... In Perl, it would be a ... imagemagick inside the script - but I would leave it out.] ...
    (rec.photo.digital)
  • Re: Free Utility That Displays RAW Pixels?
    ... You opinion noted... ... any validity, too.) ... imagemagick inside the script - but I would leave it out.] ... Floyd L. Davidson ...
    (rec.photo.digital)
  • Re: redirect the output to a file
    ... > Floyd L. Davidson wrote: ... Also see the "script" command. ...
    (comp.os.linux.misc)
  • Re: function definition syntax
    ... :> In which case it might as well be a separate script - you don't need a function. ... :>: That's much more reliable than having to remember which syntax ... Always using POSIX ... :> not overlook restoring IFS. ...
    (comp.unix.shell)