• Re: Any bash shell experts

    From Sylvia Else@21:1/5 to Sylvia Else on Wed Aug 24 14:05:56 2022
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Sylvia Else@21:1/5 to All on Wed Aug 24 13:41:18 2022
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Sylvia Else@21:1/5 to Sylvia Else on Wed Aug 24 14:23:24 2022
    On 24-Aug-22 2:05 pm, Sylvia Else wrote:
    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.

    Pathname expansion. Disable by set -f, enable again by set +f

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Spiros Bousbouras@21:1/5 to Sylvia Else on Wed Aug 24 04:20:50 2022
    On Wed, 24 Aug 2022 13:41:18 +1000
    Sylvia Else <sylvia@email.invalid> wrote:
    If I do

    X="my[[:space:]]spc[[:space:]]dir"
    echo $X

    the output is unexpectedly

    my spc dir
    [...]

    comp.unix.shell is a better place for shell questions.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Kettlewell@21:1/5 to Sylvia Else on Wed Aug 24 08:26:46 2022
    Sylvia Else <sylvia@email.invalid> 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*

    --
    https://www.greenend.org.uk/rjk/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Sylvia Else@21:1/5 to Richard Kettlewell on Wed Aug 24 19:59:14 2022
    On 24-Aug-22 5:26 pm, Richard Kettlewell wrote:
    Sylvia Else <sylvia@email.invalid> 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*


    Yes. Unfortunately, in this case I need word splitting, just not path
    name expansion.

    Sylvia.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Kettlewell@21:1/5 to Sylvia Else on Wed Aug 24 14:12:03 2022
    Sylvia Else <sylvia@email.invalid> writes:
    Richard Kettlewell wrote:
    Sylvia Else <sylvia@email.invalid> 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*


    Yes. Unfortunately, in this case I need word splitting, just not path
    name expansion.

    Less weird languages are available...

    --
    https://www.greenend.org.uk/rjk/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Sylvia Else@21:1/5 to Richard Kettlewell on Thu Aug 25 00:08:11 2022
    On 24-Aug-22 11:12 pm, Richard Kettlewell wrote:
    Sylvia Else <sylvia@email.invalid> writes:
    Richard Kettlewell wrote:
    Sylvia Else <sylvia@email.invalid> 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*


    Yes. Unfortunately, in this case I need word splitting, just not path
    name expansion.

    Less weird languages are available...


    True.

    I'm invoking a lot of standard utilities. However, I've come to think
    I'd have been better off invoking them from a more conventional
    programming languages.

    Oh well.

    Sylvia.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From scott@alfter.diespammersdie.us@21:1/5 to Sylvia Else on Wed Aug 24 15:54:20 2022
    Sylvia Else <sylvia@email.invalid> 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

    What version of bash are you using? Mine returns this for bash --version:

    GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)

    This is on Gentoo Linux running in WSL 2 on Win11. Another host running
    Gentoo on the metal behaves the same way.

    --
    _/_
    / v \ Scott Alfter (remove the obvious to send mail)
    (IIGS( https://alfter.us/ Top-posting!
    \_^_/ >What's the most annoying thing on Usenet?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bob Eager@21:1/5 to scott on Wed Aug 24 16:05:29 2022
    On Wed, 24 Aug 2022 15:54:20 +0000, scott wrote:

    Sylvia Else <sylvia@email.invalid> 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.



    --
    Using UNIX since v6 (1975)...

    Use the BIG mirror service in the UK:
    http://www.mirrorservice.org

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From scott@alfter.diespammersdie.us@21:1/5 to Bob Eager on Thu Aug 25 16:44:37 2022
    Bob Eager <news0009@eager.cx> wrote:
    On Wed, 24 Aug 2022 15:54:20 +0000, scott wrote:

    Sylvia Else <sylvia@email.invalid> 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.

    Yeah...saw that shortly after I'd posted. That's what happens when you
    don't read the whole thread first. :)

    --
    _/_
    / v \ Scott Alfter (remove the obvious to send mail)
    (IIGS( https://alfter.us/ Top-posting!
    \_^_/ >What's the most annoying thing on Usenet?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)