12/25/2023 0 Comments Winclone error 72![]() You get the error because process substitution (the <(some command) part) is not a standard feature (defined in POSIX) in sh, which means it may work on some OS but may not in others or in the same OS with different configuration. Note also that although it is conventional for some other language interpreters (Python, especially), it is not conventional to use env in shell script shebang lines. When you instead launch it as shown in the question, by naming it as an argument to sh, the shebang line is just a comment, and Bash runs (as sh) in POSIX mode. ![]() Note well that the shebang line at the top of your script has a functional role only when you launch the script directly, by making it executable and launching it by name. There is more than one way to get Bash running in POSIX mode, but one of them is to invoke it via the name sh, which is what you are doing. It is not recognized by most other shells, and it is not recognized by Bash itself when it runs in POSIX mode. Process substitution is a Bash extension to the POSIX shell language. These are the two fragments of the form <( command ). is the line 72 referenced in the error message, the issue is most likely with your process substitutions. command substitution: line 72: syntax error near unexpected token `(' Just remember escaped double quotes are not interpreted as string delimiters, they are literal double quotes. Of course, just executing the curl command without capturing it in a variable is simpler. The following would have worked : vm_name=$(curl ) Therefore, you are not echoing $vm_name preceded and followed by empty lines : you are actually echoing ", having empty command lines (doing nothing), and then trying to execute the content of vm_name expanded, subject to word splitting, and then seen as a command followed by arguments (which understandably fails). By escaping the double quotes, you prevent them from being parsed as syntactic quotes (they are interpreted as literal quotes). While you have found a solution to your problem, it is worth explaining your problem. bash: command substitution: syntax error near unexpected token |' See also: role of shebang at unix.SE syntax error: ( unexpected when sh a file script.sh do I get your error, as commented by Cyrus. script.sh after setting it to executable. script.sh or making use of the shebang by. ![]() You should run your script with bash, i.e. Bash script process substitution Syntax error: ( unexpected Always invoke bash by name if you use bash features.Īlso take care not to set the environment variable POSIXLY_CORRECT or to pass the -posix option on the command line if you want to use bash features.Īlternatively, don't use this bash-specific syntax use a portable construct such as the one proposed by Stephane Rouberol. #!/bin/sh won't do, even if /bin/sh is a symbolic link to bash, because bash runs in POSIX mode if it's invoked under the name sh. Take care to invoke your script with an explicit #!/bin/bash line. Given the error message you're getting, you are running this script in bash, but in its POSIX compatibility mode, not in full bash mode. (Ksh also has >(…) process substitution but doesn't support it after a redirection. The syntax you've used is a bash extension to the basic shell syntax, so you must take care to run your script with bash. Syntax error in shell script with process substitution
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |