Re: a quick tip that sometimes saves a lot of further worries
- Date: Thu, 25 Oct 2018 21:48:31 +0200
- From: Étienne Mollier <etienne.mollier@xxxxxxxxxx>
- Subject: Re: a quick tip that sometimes saves a lot of further worries
On 10/25/18 9:35 PM, Greg Wooledge wrote:
> On Thu, Oct 25, 2018 at 09:21:27PM +0200, Étienne Mollier wrote:
>> for arg in "$@"
>> if [ -f "$arg" ]
>> printf '<<< %s >>>\n' "$arg"
>> cat "./$arg"
> The ./ breaks the function if you give it absolute pathnames. Replace
> this last line with cat -- "$arg" instead.
Got the brain messed with some ./--help file to remove, again...
And since some programs don't (didn't) implement "--", well the
broken solution went first...
> A "clever" version of this part of the function that does something
> similar in a more compact form is:
> tail -n +1 -- "$@"
That's neat! :-D
It may spew a few errors if for some reason, options are passed to
the editor, and is a little less flexible if we want to add, say
date information, nevertheless cool!
> I didn't write that and can't claim credit for it, but I don't know who
> did, so I can't give appropriate credit either.
I suppose those gentlemen can earn a bit of credit for having
implemented it in "tail" in the first place then, if I trust the
> Written by Paul Rubin, David MacKenzie, Ian Lance Tay‐
> lor, and Jim Meyering.
Étienne Mollier <etienne.mollier@xxxxxxxxxx>