bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] tests: avoid problematic $(< file) shell construct


From: Bernhard Voelker
Subject: Re: [PATCH] tests: avoid problematic $(< file) shell construct
Date: Mon, 16 Dec 2013 18:31:09 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0

On 12/16/2013 05:10 PM, Pádraig Brady wrote:
> On 12/16/2013 02:53 PM, Bernhard Voelker wrote:
>> The check is quite rough anyway because nothing prevents
>> a user from writing a command after the redirection:
>>
>>   u="$(</etc/passwd  head -n1 | cut -d: -f1)"
>>
>> However, I think such use is very rare.
> 
> Well not really. You could easily have $(<file tr blah BLAH) for example.

Sure, but this is a valid command.  It is only unportable to have
a command which is redirection-only, i.e. a command which does not
execute another program.

> While this could be reordered, I suppose the re should only match
> there is no space or no | after the initial name.

Hmm, catching spaces is a bit harder, because

  x="$(< 'file name' tr blah BLAH)"
  x="$(<'file name' tr blah BLAH)"
  x="$(<file\ name tr blah BLAH)"

are all okay while

  x="$(< 'file name')"
  x="$(<'file name')"
  x="$(<file\ name)"

are not.

> I suppose we should also handle `< file`.

Good point.

Have a nice day,
Berny




reply via email to

[Prev in Thread] Current Thread [Next in Thread]