bug-bash
[Top][All Lists]
Advanced

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

Re: echo builtin command will give the wrong value of the variable when


From: Pierre Gaston
Subject: Re: echo builtin command will give the wrong value of the variable when there is a file named: 11 in the current directory
Date: Wed, 27 Jul 2016 16:27:26 +0300



On Wed, Jul 27, 2016 at 2:28 PM, Lingfei Kong <address@hidden> wrote:
Another reproducer:

# c='[1][1][1]'
# touch 111
# echo $c
111
# rm 111
# echo $c
[1][1][1]

------------------ Original ------------------
From:  "Lingfei Kong";<address@hidden>;
Date:  Wed, Jul 27, 2016 07:24 PM
To:  "bug-bash"<address@hidden>;
Subject:  echo builtin command will give the wrong value of the variable when there is a file named: 11 in the current directory

Description:
echo builtin command will give the wrong value of the variable  when there is a file named: 11 in the current directory.

Version:
GNU bash, version 4.2.45(1)-release-by_tst_tlinux20_v1004 (x86_64-unknown-linux-gnu)
GNU bash, version 4.1.2(1)-release-by_mupan_tlinux_v1004 (x86_64-unknown-linux-gnu)
GNU bash, version 3.2.48(1)-release-by_tst_suse_31_v1004 (x86_64-unknown-linux-gnu)

How reproducible:
100%

Steps to Reproduce:
# touch 11
# c='[11761][1469504252]'
# echo $c
11

# rm 11
# echo $c
[11761][1469504252]
Expected results:
# touch 11
# c='[11761][1469504252]'
# echo $c
[11761][1469504252]


Best Regards
Lingfei
It's acutally a feature, juste like "echo *" will print the list of filenames matching *  "echo [a-z]*" will print the list of filenames starting with a letter between a and z.

[]  defines a range of character like in almost every regular _expression_.

In your case you can disable matching the filenames by quoting your expansion: echo "$c".

reply via email to

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