3 ms·
I said "Give me the most succinct possible idiom" and it gave me the answer you were looking for: https://chat.openai.com/share/05a3d1aa-cd60-40a1-b6d5-ec0c9f63
by simonw 3y ago
I said "Give me the most succinct possible idiom" and it gave me the answer you were looking for: https://chat.openai.com/share/05a3d1aa-cd60-40a1-b6d5-ec0c9f63b1c0 https://chat.openai.com/share/05a3d1aa-cd60-40a1-b6d5-ec0c9f...
- mgdlbp 3y agoThe first answer is wrong, so is the second's explanation... twice it conflates unset with null/empty. Very illustrative! The substance of the first answer: #!/bin/bash # Check if the first parameter is not provided if [ -z "$1" ]; then echo "Error: Parameter not provided." exit 1 fi The snippet precedes the true statement: > This checks if the first parameter (`$1`) is empty. But what happened to the supplied task? It was stated and echoed as: > Anonymous: ...if it's not passed? > ChatGPT: ...if a specific parameter is not passed... > ChatGPT: ...if the parameter is set. The second answer: #!/bin/bash : ${1?"Error: Parameter not provided"} This is correct. But the explanation is not: > ...and the `${1?...}` part checks if the first positional parameter (`$1`) is unset or null. -- (the most succinct possible idiom is `#!/bin/bash -u`)