If I do
X="my[[:space:]]spc[[:space:]]dir"
echo $X
the output is unexpectedly
my spc dir
but do
X="m[[:space:]]spc[[:space:]]dir"
echo $X
and the output is the expected
m[[:space:]]spc[[:space:]]dir
Indeed, I cannot find any change to my original assignment that leads to
the unexpected behaviour.
Is there some logic behind this, or have I stumbled, completely by
chance, onto some bizarre "easter egg", and thereby lost considerable
time, and some amount of hair?
What the hell.........?
Sylvia.
On 24-Aug-22 1:41 pm, Sylvia Else wrote:
If I do
X="my[[:space:]]spc[[:space:]]dir"
echo $X
the output is unexpectedly
my spc dir
but do
X="m[[:space:]]spc[[:space:]]dir"
echo $X
and the output is the expected
m[[:space:]]spc[[:space:]]dir
Indeed, I cannot find any change to my original assignment that leads
to the unexpected behaviour.
Is there some logic behind this, or have I stumbled, completely by
chance, onto some bizarre "easter egg", and thereby lost considerable
time, and some amount of hair?
What the hell.........?
Sylvia.
OK, seem it's pattern matching against a directory of that name, with
the embedded spaces in its name, which is how this pattern matching
pattern arose in the first place.
All I need to do now is find out where it's documented that it will do
that without being expressly told to.
Sylvia.
If I do[...]
X="my[[:space:]]spc[[:space:]]dir"
echo $X
the output is unexpectedly
my spc dir
Pathname expansion. Disable by set -f, enable again by set +f
Sylvia Else <[email protected]d> writes:
Pathname expansion. Disable by set -f, enable again by set +f
That’s a global setting. The usual approach is to quote all string expansions except the few where you want pathname expansion.
richard@araminta:~$ x="j*"
richard@araminta:~$ echo $x
junk
richard@araminta:~$ echo "$x"
j*
Richard Kettlewell wrote:
Sylvia Else <[email protected]d> writes:
Pathname expansion. Disable by set -f, enable again by set +fThat’s a global setting. The usual approach is to quote all string
expansions except the few where you want pathname expansion.
richard@araminta:~$ x="j*"
richard@araminta:~$ echo $x
junk
richard@araminta:~$ echo "$x"
j*
Yes. Unfortunately, in this case I need word splitting, just not path
name expansion.
Sylvia Else <[email protected]d> writes:
Richard Kettlewell wrote:
Sylvia Else <[email protected]d> writes:
Pathname expansion. Disable by set -f, enable again by set +fThat’s a global setting. The usual approach is to quote all string
expansions except the few where you want pathname expansion.
richard@araminta:~$ x="j*"
richard@araminta:~$ echo $x
junk
richard@araminta:~$ echo "$x"
j*
Yes. Unfortunately, in this case I need word splitting, just not path
name expansion.
Less weird languages are available...
If I do
X="my[[:space:]]spc[[:space:]]dir"
echo $X
the output is unexpectedly
my spc dir
Sylvia Else <[email protected]d> wrote:
If I do
X="my[[:space:]]spc[[:space:]]dir"
echo $X
the output is unexpectedly
my spc dir
Not for me:
salfter@salfter ~ $ X="my[[:space:]]spc[[:space:]]dir" salfter@salfter ~
$ echo $X my[[:space:]]spc[[:space:]]dir
On Wed, 24 Aug 2022 15:54:20 +0000, scott wrote:
Sylvia Else <[email protected]d> wrote:
If I do
X="my[[:space:]]spc[[:space:]]dir"
echo $X
the output is unexpectedly
my spc dir
Not for me:
salfter@salfter ~ $ X="my[[:space:]]spc[[:space:]]dir" salfter@salfter ~
$ echo $X my[[:space:]]spc[[:space:]]dir
I think it's been established that the behaviour is dependent on having
files in the current directory that match the pattern.
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 715 |
| Nodes: | 16 (2 / 14) |
| Uptime: | 34:58:02 |
| Calls: | 12,109 |
| Files: | 15,006 |
| Messages: | 6,518,345 |