ksh88 changing single quotes to double quotes inside heredocs?

后端 未结 1 566
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-10 05:52

I seem to be running into an issue that\'s specific to ksh88 that\'s changing single quotes to double quotes, but only under certain situations involving heredocs and comman

1条回答
  •  无人及你
    2020-12-10 06:08

    Here are my notes when I discovered this same bug several years ago.

    Test script:

    #!/bin/ksh
    cat <

    Output for different shells:

    • Linux KSH Version M 1993-12-28 q
    • Linux Bash 3.00.15(1)

    (NOTE: works as expected)

     /home/jrw32982 "/home/jrw32982" '/home/jrw32982'
     /home/jrw32982 "/home/jrw32982" '/home/jrw32982'
     /home/jrw32982 "/home/jrw32982" '/home/jrw32982'
    
    • AIX Version M-11/16/88f
    • Solaris Version M-11/16/88i

    (NOTE: single quotes replaced with double quotes and variable not substituted)

     /home/jrw32982 "/home/jrw32982" '/home/jrw32982'
     /home/jrw32982 "/home/jrw32982" '/home/jrw32982'
     /home/jrw32982 "/home/jrw32982" "$PWD"
    

    Work-around:

    1. Compute the single-quoted string externally from the here-file

      abc=xyz
      STR="'$abc'"
      x=$( cat <
    2. Use the here-file in a function instead of directly

      fn() {
        cat <

    0 讨论(0)
提交回复
热议问题