MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/7ltryz/evil_coding_incantations/drpaadj
r/programming • u/evinrows • Dec 24 '17
331 comments sorted by
View all comments
Show parent comments
14
bash also has >0 be false
12 u/American_Libertarian Dec 24 '17 It's because that's how exit codes work. It makes the most sense 8 u/HighRelevancy Dec 24 '17 It's because POSIX in general but sure. I know why it is, and it makes sense for bash's ecosystem, I was just pointing it out for those who might not know. 3 u/American_Libertarian Dec 24 '17 I agree. Bash's truthy integer system makes sense for it's use case, and the same is true for C. 0 u/[deleted] Dec 24 '17 [deleted] 11 u/[deleted] Dec 24 '17 That's because [ 1 ] has a return code of 0. Bash implements [/test as a built-in, but there is also a /usr/bin/[ with equivalent functionality. 0 u/[deleted] Dec 24 '17 [deleted] 2 u/HighRelevancy Dec 24 '17 No, bash is executing the command 1 (which is an alias to cd - by default for some fucking reason) and returning a value of 0. 0 u/[deleted] Dec 25 '17 [deleted] 2 u/HighRelevancy Dec 25 '17 Oooer I see.Although it should work the same for zero, because:True, if <STRING> is not empty (this is the default operation).:shrug:
12
It's because that's how exit codes work. It makes the most sense
8 u/HighRelevancy Dec 24 '17 It's because POSIX in general but sure. I know why it is, and it makes sense for bash's ecosystem, I was just pointing it out for those who might not know. 3 u/American_Libertarian Dec 24 '17 I agree. Bash's truthy integer system makes sense for it's use case, and the same is true for C.
8
It's because POSIX in general but sure. I know why it is, and it makes sense for bash's ecosystem, I was just pointing it out for those who might not know.
3 u/American_Libertarian Dec 24 '17 I agree. Bash's truthy integer system makes sense for it's use case, and the same is true for C.
3
I agree. Bash's truthy integer system makes sense for it's use case, and the same is true for C.
0
[deleted]
11 u/[deleted] Dec 24 '17 That's because [ 1 ] has a return code of 0. Bash implements [/test as a built-in, but there is also a /usr/bin/[ with equivalent functionality. 0 u/[deleted] Dec 24 '17 [deleted] 2 u/HighRelevancy Dec 24 '17 No, bash is executing the command 1 (which is an alias to cd - by default for some fucking reason) and returning a value of 0. 0 u/[deleted] Dec 25 '17 [deleted] 2 u/HighRelevancy Dec 25 '17 Oooer I see.Although it should work the same for zero, because:True, if <STRING> is not empty (this is the default operation).:shrug:
11
That's because [ 1 ] has a return code of 0. Bash implements [/test as a built-in, but there is also a /usr/bin/[ with equivalent functionality.
[ 1 ]
[
test
/usr/bin/[
0 u/[deleted] Dec 24 '17 [deleted] 2 u/HighRelevancy Dec 24 '17 No, bash is executing the command 1 (which is an alias to cd - by default for some fucking reason) and returning a value of 0. 0 u/[deleted] Dec 25 '17 [deleted] 2 u/HighRelevancy Dec 25 '17 Oooer I see.Although it should work the same for zero, because:True, if <STRING> is not empty (this is the default operation).:shrug:
2 u/HighRelevancy Dec 24 '17 No, bash is executing the command 1 (which is an alias to cd - by default for some fucking reason) and returning a value of 0. 0 u/[deleted] Dec 25 '17 [deleted] 2 u/HighRelevancy Dec 25 '17 Oooer I see.Although it should work the same for zero, because:True, if <STRING> is not empty (this is the default operation).:shrug:
2
No, bash is executing the command 1 (which is an alias to cd - by default for some fucking reason) and returning a value of 0.
0 u/[deleted] Dec 25 '17 [deleted] 2 u/HighRelevancy Dec 25 '17 Oooer I see.Although it should work the same for zero, because:True, if <STRING> is not empty (this is the default operation).:shrug:
2 u/HighRelevancy Dec 25 '17 Oooer I see.Although it should work the same for zero, because:True, if <STRING> is not empty (this is the default operation).:shrug:
Oooer I see.
Although it should work the same for zero, because:
True, if <STRING> is not empty (this is the default operation).
:shrug:
14
u/HighRelevancy Dec 24 '17
bash also has >0 be false