On Tue, 11 Nov 2014, Greg Reagle wrote:
> That's very interesting. I get the same problem. I don't think
> anything is wrong with your code. I think something fishy is going on
> with fish, but I don't know what. It looks like it might even be a bug
> in fish. I would expect test -n to be the
On Tue, Nov 11, 2014, at 05:51 PM, Glenn Jackman wrote:
> I suspect what is happening (this is true in bash, I'm speculating about
> fish) is that an unset variable is substituted with nothing (not the
> empty
> string, but with nothing). Then the `test` command receives exactly one
> argument: "-n
On 2014-11-12 00:03, Marcin Zajączkowski wrote:
> On 2014-11-11 23:54, Glenn Jackman wrote:
>> Marcin, applying this to the 2-variable question:
>>
>> $ test "$SSH_TTY$SSH_CLIENT"; and echo "not empty"; or echo "unset or empty"
>>> unset or empty
>>> $ ssh localhost
>>> [...]
>>> $ test "$SSH_TTY$S
On 2014-11-11 23:54, Glenn Jackman wrote:
> Marcin, applying this to the 2-variable question:
>
> $ test "$SSH_TTY$SSH_CLIENT"; and echo "not empty"; or echo "unset or empty"
>> unset or empty
>> $ ssh localhost
>> [...]
>> $ test "$SSH_TTY$SSH_CLIENT"; and echo "not empty"; or echo "unset or
>> e
Marcin, applying this to the 2-variable question:
$ test "$SSH_TTY$SSH_CLIENT"; and echo "not empty"; or echo "unset or empty"
> unset or empty
> $ ssh localhost
> [...]
> $ test "$SSH_TTY$SSH_CLIENT"; and echo "not empty"; or echo "unset or
> empty"
> not empty
On Tue, Nov 11, 2014 at 5:51 PM,
On 2014-11-11 23:44, Greg Reagle wrote:
> On Tue, Nov 11, 2014, at 05:29 PM, Marcin Zajączkowski wrote:
>> The next problem I encounter is how to check two variables in one if
>> statement.
>
> There are several ways of doing this. Here is one:
> set -q $COLUMNS $LINES; if test $status = 2; e
I suspect what is happening (this is true in bash, I'm speculating about
fish) is that an unset variable is substituted with nothing (not the empty
string, but with nothing). Then the `test` command receives exactly one
argument: "-n". When `test` is given a single argument, the result is true
if t
That's very interesting. I get the same problem. I don't think
anything is wrong with your code. I think something fishy is going on
with fish, but I don't know what. It looks like it might even be a bug
in fish. I would expect test -n to be the opposite of test -z, but that
is not true someti
On 2014-11-11 22:49, Glenn Jackman wrote:
> You might want to test if the variable is set first:
Thanks Glenn, that works.
The next problem I encounter is how to check two variables in one if
statement. I tried with |and| keyword and with |test| joined with |-a|,
but it fails?
|if set -q SSH_TTY
You might want to test if the variable is set first:
$ function ntest
> if not set -q NOT_SET_VARIABLE
> echo "not set"
> else if test -n $NOT_SET_VARIABLE
> echo "Non-zero"
> echo $NOT_SET_VARIABLE
> else
> echo
Hi,
I wanted to write a script which display different prompt for session
made through SSH. SSH should set SSH_CLIENT and SSH_TTY variables, so it
should be easy to check. Unfortunately I am unable to write working if
for those two cases. In the end it seem that even simple test with “-n”
from man
11 matches
Mail list logo