On Wed, Feb 29, 2012 at 10:24 AM, Henry M <span dir="ltr"><<a href="mailto:henry95@gmail.com">henry95@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
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<br></blockquote><div><br></div><div>sh(1) binds stdin to tty if there is nothing on stdin, e.g.:</div>
<div><br></div><div><div>$ xargs echo</div><div>hi</div><div>you</div><div>guys</div><div>^Dhi you guys</div></div><div>$ grep foo</div><div>bar</div><div>baz</div><div>foo</div><div>foo</div><div>^D</div><div><br></div><div>
This is also how ed(1) works ... ! Very nifty indeed.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>Sample:<br><blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">

$ cat >filename<br>Hello, Talk<br>^D<br>$ cat filename<br>Hello, Talk<br></blockquote><br>Regards,<br>-Henry<br><br><div class="gmail_quote">On Thu, Dec 15, 2011 at 9:24 PM, William Baxter <span dir="ltr"><<a href="mailto:web-nycbug@superscript.com" target="_blank">web-nycbug@superscript.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Excerpts from Matthew Story's message of Thu Dec 15 00:54:<a href="tel:24%20-0500%202011" value="+12405002011" target="_blank">24 -0500 2011</a>:<br>


<div>> i believe the most portable version is slightly uglier:<br>
><br>
> On Dec 14, 2011, at 6:13 PM, Isaac Levy wrote:<br>
><br>
> >  shout() { echo "$0: $*" >&2; }<br>
> >  barf() { shout "$*"; exit 111; }<br>
> safe() { ${1+"$@"} || barf "cannot $*"; }<br>
>           ^^^^^^^^ this bit is more reliable for sh on Solaris (real Bourne shell)<br>
><br>
<br>
</div>Delightful as the topic of Solaris compatibility may be I don't think it's worth<br>
going that far.  The ${1+"$@"} construct is indispensable for compatibility in<br>
cases when an empty list is legitimate while an unintended empty argument is<br>
not:<br>
<br>
  for ${1+"$@"}<br>
<br>
versus<br>
<br>
  for "$@"<br>
<br>
But an empty string and an empty list are both erroneous for safe().  While the<br>
execution details may vary from shell to shell, I consider it a case of pilot<br>
error to pass in either an empty argument or no argument to a function that<br>
requires a program.  A function cannot ultimately protect the caller from his<br>
own error.<br>
<br>
Cheers, W.<br>
<div><div>_______________________________________________<br>
talk mailing list<br>
<a href="mailto:talk@lists.nycbug.org" target="_blank">talk@lists.nycbug.org</a><br>
<a href="http://lists.nycbug.org/mailman/listinfo/talk" target="_blank">http://lists.nycbug.org/mailman/listinfo/talk</a><br>
</div></div></blockquote></div><br>
<br>_______________________________________________<br>
talk mailing list<br>
<a href="mailto:talk@lists.nycbug.org">talk@lists.nycbug.org</a><br>
<a href="http://lists.nycbug.org/mailman/listinfo/talk" target="_blank">http://lists.nycbug.org/mailman/listinfo/talk</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>regards,<br>matt<br>