[Top][All Lists]

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

Re: -eq and strings

From: Rob la Lau
Subject: Re: -eq and strings
Date: Mon, 6 Mar 2017 15:09:39 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:45.0) Gecko/20100101 Thunderbird/45.7.1

On 06-03-17 14:18, Greg Wooledge wrote:
> You're misunderstanding.  In a math context, which you are creating here
> by using -eq, the word 'x' is interpreted as a variable name, which may
> contain another variable name, and so on, until finally an integer is
> discovered.

Thanks. Now that I know it, I can indeed find it in the docs.

I guess this means that actually test and [ are 'broken':

$ test "x" -eq "x" && echo "yes" || echo "no"
test: invalid integer 'x'

$ [ "x" -eq "x" ] && echo "yes" || echo "no"
[: invalid integer 'x'

I hope this won't be fixed, as I rely quite heavily on this behaviour,
lacking some other short 'is integer' test.


-- Rob la Lau
-- Sysadmin en webdeveloper in ruste
--      web : https://ohreally.nl/
--      eml : address@hidden

reply via email to

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