[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] tests: avoid problematic $(< file) shell construct
From: |
Pádraig Brady |
Subject: |
Re: [PATCH] tests: avoid problematic $(< file) shell construct |
Date: |
Mon, 16 Dec 2013 16:10:59 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 |
On 12/16/2013 02:53 PM, Bernhard Voelker wrote:
> On 12/16/2013 03:27 PM, Eric Blake wrote:
>> On 12/15/2013 12:59 PM, Bernhard Voelker wrote:
>>
>>> +# Avoid problematic redirect-only statements in $(...) shell construct.
>>> +# Although the "man bash" states that this is faster, it does not seem
>>> +# to be portable. Issues have been seen on dash v0.5.6 and on the shell
>>> +# on FreeBSD.
>>> +sc_prohibit_redirect_only_command_substitution:
>>> + @prohibit='\$$\(<' \
>>
>> Shouldn't you also prevent $(> ...)?
>
> Maybe yes, but I don't think that it's use is very likely,
> because one wanting to create a file that way would most
> probably do it without the $(...) command substitution.
>
> 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.
While this could be reordered, I suppose the re should only match
there is no space or no | after the initial name.
I suppose we should also handle `< file`.
thanks,
Pádraig.