• DoomBot5@lemmy.world
    link
    fedilink
    English
    arrow-up
    8
    ·
    1 year ago

    First one has the pitfall of a space at the end of the variable still causing it to fail.

      • DoomBot5@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 year ago

        It would still be considered a single variable because the entire string is quoted. The first scenario would have split it into 2 variables.

    • LemoineFairclough@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      1
      ·
      22 days ago

      I don’t think this is correct. Consider what you see from using sh -c -- 'var="a " && printf "%s\n" "${var}"-z'

      If "${var}"-z resulted in two arguments instead of one, I’d see “a” and “-z” on different lines, but I see them on the same line, which means they are treated as a single argument.