lkml.org 
[lkml]   [1999]   [Mar]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: GNU/Linux stance by Richard Stallman
Date
Jamie Lokier enscribed thusly:
> H. Peter Anvin wrote:
> > > > Actually it is: true and false are supposed to IGNORE their command
> > > > lines. I consider "true --help" and "true --version" to be BUGS.

> > > Hmmm.... Why tru and false should ignore their coomand lines ? If you want
> > > something to be ignored then why to supply it's at all ?

> > Because they can be used to substitute out commands.

> On all systems I've encountered, `:' is a perfectly good command for not
> doing anything. Is it too new to be portable?

Oh... Believe it or not ":" does more than nothing (or rather you
can do a lot with nothing...).

That's actually part of the basic syntax of the bourne shell
and consequently any sh compatable shells such as bash. It tell the
shell to evaluate the command line as if it were going to perform a
command but then do not actually execute any command. It's also a neat
way to comment out a multiline command (since it obeys shell continuation
line syntax) by prepending a colon in front of the command you are
commenting out, rather than commenting out each line and continuation line.

It may seem silly to "evaluate" a command line if you are not
going to perform any command, but there are some neat embedded variable
substitutions which you can take advantage of.

Pop quiz... What effect does the following statement have on the
environment variable "REPORT" if the variable already exists? If the
variable does not already exist? If the variable exists but is NULL?
What would any following commands see for the value of the variable "REPORT"?

: ${REPORT:=$HOME/reports}

Yes there are other ways of accomplishing this effect... This is
just a neat and effective one liner to do a conditional set on a variable.


":" evaluates to true by the shell and would substitute for true
quite nicely.

I don't know of C shell (csh) has the same thing or something similar
(since I do very little csh script programming any more) but I would not be
surprised if it supported the same thing.

> -- Jamie

Mike
--
Michael H. Warfield | (770) 985-6132 | mhw@WittsEnd.com
(The Mad Wizard) | (770) 925-8248 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0xDF1DD471 | possible worlds. A pessimist is sure of it!


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:51    [W:0.057 / U:0.196 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site