read: Illegal option -d

前端 未结 2 1668
借酒劲吻你
借酒劲吻你 2020-12-17 16:23

Here is the offending part of my script:

read -d \'\' TEXT <<\'EOF\'
Some Multiline
text that
I would like
in 
a 
var
EOF

echo \"$TEXT\" > ~/some/f         


        
2条回答
  •  星月不相逢
    2020-12-17 16:38

    The -d option to read is a feature unique to bash, not part of the POSIX standard (which only specifies -r and -p options to read). When you run your script with sh on Ubuntu, it's getting run with dash, which is a POSIX shell, and not bash. If you want the script to run under bash then you should run it with bash, or give it a #!/bin/bash shebang. Otherwise, it should be expected to run under any POSIX sh.

提交回复
热议问题