[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: test ~ expand
From: |
Bob Proulx |
Subject: |
Re: test ~ expand |
Date: |
Wed, 26 Feb 2003 23:40:00 -0700 |
User-agent: |
Mutt/1.3.28i |
PADURARIU Lucian Ionut wrote:
>
> given :
> in ~joe a file named a.txt
> and the next script :
First off you are not reporting a bug. This is a bug reporting
mailing list. You are not even talking about anything to do with
sh-utils which is the focus of this list. You are just asking for
basic help with shell programming. This is not the appropriate forum
for that.
I suggest you try asking your question in one of the unix user lists
or news groups.
> ------------
> #!/bin/bash
> $a=joe
> test -e ~$a/a.txt && echo "yes"
> ------------
>
> it does not output anything.
> WHY NOT ????????
Well, as long as I am here, but don't make this a habit! Because "$a"
is not a user that can be expanded with ~user. You need to 'eval' the
line to get another shell processing pass across it.
#!/bin/sh
$a=joe
eval test -e ~$a/a.txt && echo "yes"
Compare this
echo ~$a/a.txt
to
eval echo ~$a/a.txt
And unless you are using bash specific features it is best if you use
#!/bin/sh instead. Standard and portable are best.
Bob
- test ~ expand, PADURARIU Lucian Ionut, 2003/02/26
- Re: test ~ expand,
Bob Proulx <=