Hello folks,
I have a question that if i type ls command and type echo $? it always show "0", how i could do this change that when i type ls it will show me 1, actually i want to change the return code of commands from 0 to 1.
Thanks
Bash
Hello folks,
I have a question that if i type ls command and type echo $? it always show "0", how i could do this change that when i type ls it will show me 1, actually i want to change the return code of commands from 0 to 1.
Thanks
Bash
bash-2.05$ ls foo
foo: No such file or directory
bash-2.05$ echo $?
2
Hello,
thanks for your reply, but i want to replace only true output to "1", ls always return "0" how could i replace only ls command output to "1".
Thanks,
Bash
no, 'ls' does not always return '0'.
here's what 'man ls' yields:
EXIT STATUS
0 All information was written successfully.
>0 An error occurred.
just curious, why would you want to return a non-zero value when 'ls' was successful?
Hello,
Thanks once again for quick reply, i understand what you are saying actually i want to make all commands return code to "1", ls is just an example.
Thanks.
Bash
Why? It's common practice in UNIX for programs to return 0 on successful exit (yes, I know it's different to C, where non-zero indicates success). If you want to change that, have fun updating and recompiling almost every util and shell for your OS.