[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: No tilde expansion right after a quotation

From: Paul Jarc
Subject: Re: No tilde expansion right after a quotation
Date: Sun, 15 Feb 2009 20:01:15 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)

"Angel Tsankov" <address@hidden> wrote:
> How do you know that $# is always set?  And what about address@hidden  To 
> what values 
> are these parameters set outside any function?

$# gives the number of positional parameters.  If there aren't any
positional parameters, then it's set to 0.  In the man page, under
PARAMETERS, Special Parameters, you'll find:
       #      Expands to the number of positional parameters in decimal.

Note that it doesn't say "while a function is being executed" or "when
some positional parameters are set".  That variable is always set, as
are the others listed under Special Parameters.

Positional parameters can be used outside of functions:
  set foo bar; echo $# $@
  bash -c 'echo $0; echo $# $@' arg-zero foo bar

> A more appropriate parameter to use could be $? which, by pure logic, seems 
> to be at least as often set as is $#.

They're both always set; pick whichever one you like.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]