3 ms·
echo is idempotent As a simple call, yes. But there are many shell tricks (redirection, command substitution, process substitution) that can make an echo call
by dspillett 13y ago
echo is idempotent
As a simple call, yes. But there are many shell tricks (redirection, command substitution, process substitution) that can make an echo call have significant side effects - so if you were daft enough to be considering this you'd need to do much more checking before submitting the provided instruction to your shell, and those checks would need to know which shell you were targeting (in fact you'd probably want to force the issue by exec()ing a specific shell instead of just using the default for the user the code is running as).
- izietto 13y agoYes, though if a shell is chosen and the command is shell escaped you are good to go