Código de salida de la sustitución de comandos en la asignación de variables locales de Bash [duplicado]

StackOverflow https://stackoverflow.com/questions/9524623

¿Fue útil?

Solución

If you look at the man file for local (which is actually just the BASH builtins man page), it is treated as its own command, which gives an exit code of 0 upon successfully creating the local variable. So local is overwriting the last-executed error code.

Try this:

function testing { local test; test="$(return 1)"; echo $?; }; testing

EDIT: I went ahead and tried it for you, and it works.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top