[nycbug-talk] nifty(1)

Henry M henry95 at gmail.com
Wed Feb 29 10:24:17 EST 2012


A cool one I came across by accident. A fun way to create a plain text
file. Redirect stdout of cat to a file, type your text, then close it with
ctrl-d

Sample:

> $ cat >filename
> Hello, Talk
> ^D
> $ cat filename
> Hello, Talk
>

Regards,
-Henry

On Thu, Dec 15, 2011 at 9:24 PM, William Baxter
<web-nycbug at superscript.com>wrote:

> Excerpts from Matthew Story's message of Thu Dec 15 00:54:24 -0500 2011:
> > i believe the most portable version is slightly uglier:
> >
> > On Dec 14, 2011, at 6:13 PM, Isaac Levy wrote:
> >
> > >  shout() { echo "$0: $*" >&2; }
> > >  barf() { shout "$*"; exit 111; }
> > safe() { ${1+"$@"} || barf "cannot $*"; }
> >           ^^^^^^^^ this bit is more reliable for sh on Solaris (real
> Bourne shell)
> >
>
> Delightful as the topic of Solaris compatibility may be I don't think it's
> worth
> going that far.  The ${1+"$@"} construct is indispensable for
> compatibility in
> cases when an empty list is legitimate while an unintended empty argument
> is
> not:
>
>  for ${1+"$@"}
>
> versus
>
>  for "$@"
>
> But an empty string and an empty list are both erroneous for safe().
>  While the
> execution details may vary from shell to shell, I consider it a case of
> pilot
> error to pass in either an empty argument or no argument to a function that
> requires a program.  A function cannot ultimately protect the caller from
> his
> own error.
>
> Cheers, W.
> _______________________________________________
> talk mailing list
> talk at lists.nycbug.org
> http://lists.nycbug.org/mailman/listinfo/talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nycbug.org/pipermail/talk/attachments/20120229/904ee072/attachment.html>


More information about the talk mailing list