bug-bash
[Top][All Lists]
Advanced

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

Re: test - StringComparisons dont work


From: Greg Wooledge
Subject: Re: test - StringComparisons dont work
Date: Mon, 2 Apr 2012 14:27:48 -0400
User-agent: Mutt/1.4.2.3i

On Mon, Apr 02, 2012 at 04:28:54PM +0200, Fidu wrote:
> test "rrr" > $x  redirects to file sss, instead of comparing.
> Any hint?

test rrr \> "$x"

or

test rrr ">" "$x"

However, it should be noted that ">" as a string comparison operator in
the test command is an extension, and not portable.  As such, it might
be better to use [[ so that you can *plainly see* that the code is using
bashisms, and is not sh-compatible.

[[ rrr > "$x" ]]

This gives you the benefit of not needing to quote the > operator, as well
as the visual clue about non-portability.



reply via email to

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