[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug Using Brackets
From: |
Harry Lee |
Subject: |
Re: Bug Using Brackets |
Date: |
Thu, 7 Jan 2021 01:37:00 +0800 |
Hi,
On Wed, Jan 06, 2021 at 17:16:26PM +0100, felix wrote:
> I use near same version, but can't reproduce:
>
> $ echo $BASH_VERSION
> 5.0.3(1)-release
>
> $ echo [0-1]
> [0-1]
>
> Please try this:
>
> $ LANG=C bash -norc -c 'echo [0-1]'
It returns the same:
root@server:~# LANG=C bash -norc -c 'echo [0-1]'
1
Thanks for Oğuz, I found that there is a file name `1` in this directory. After
I removed it, it shows normally:
root@server:~# rm 1
root@server:~# echo [0-1]
[0-1]
On server2 there is no such a file, so it just echo what I input.
This problem doesn't related to the version.
Here's the document:
https://www.gnu.org/software/bash/manual/bash.html#index-pathname-expansion
<https://www.gnu.org/software/bash/manual/bash.html#index-pathname-expansion>
> After word splitting, unless the -f option has been set (see The Set Builtin
> <https://www.gnu.org/software/bash/manual/bash.html#The-Set-Builtin>), Bash
> scans each word for the characters ‘*’, ‘?’, and ‘[’. If one of these
> characters appears, and is not quoted, then the word is regarded as a
> pattern, and replaced with an alphabetically sorted list of filenames
> matching the pattern (see Pattern Matching
> <https://www.gnu.org/software/bash/manual/bash.html#Pattern-Matching>). If no
> matching filenames are found, and the shell option nullglob is disabled, the
> word is left unchanged. If the nullglob option is set, and no matches are
> found, the word is removed. If the failglob shell option is set, and no
> matches are found, an error message is printed and the command is not
> executed. If the shell option nocaseglob is enabled, the match is performed
> without regard to the case of alphabetic characters.
--
Harry Lee