scripting, no-op statements in bash function (was: SATA hot swap)

VirginSnow at vfemail.net VirginSnow at vfemail.net
Wed Jun 10 12:32:38 EDT 2009


In message <20090610153306.88BE3918088 at c-98-216-200-60.hsd1.ma.comcast.net>, "Michael ODonnell" writes:
> 
> 
> I had a look at /sbin/rescan-scsi-bus.sh - it's not the most elegant

> One thing I noticed was that some of the functions in that script are
> constructed thus:
> 
>     funcName ()
>     {
>       : funcName
>       otherStuffHere
>     }
> 
> ...and I wonder if those no-op constructions have some value, maybe
> during development or debugging, maybe forcing the function name into
> a parameter list?

Two possibilities come to mind: grepping for ": funcName" and storing
funcName in $_.  Grepping for ": funcName" might be an easy way to
find where a function is defined if the source is spread out among
many files and none of the files contain any comments.

Assuming bash, using ": funcName" also stores "funcName" in the
special variable $_.  Normally, this is initially set to the name of
the executable or script.  If every function begins with ": funcName",
$_ would instead hold the name of the function, as opposed to the name
of the script.  Depending on what "otherStuffHere" does, this
information may be useful to the code that follows.  I do not have a
copy of /sbin/rescan-scsi-bus.sh.  Does it make any references to $_?


More information about the gnhlug-discuss mailing list