Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
oneshtein
on Nov 22, 2024
|
parent
|
context
|
favorite
| on:
TIL: Some surprising code execution sources in bas...
Instead of `if [[ "${num}" -eq 42 ]]`, bash expects `if [ "${num}" -eq 42 ]` or `if (( num==42 ))`.
tpoacher
on Nov 22, 2024
|
next
[–]
or if test $num -eq 42, which is the most sensible way to do it in my view, since it really makes the point clear that what you're really evaluating is the exit status of the evaluated command
(and where '[' is simply an alias to 'test')
jwilk
on Nov 22, 2024
|
prev
[–]
"if (( num==42 ))" can exectue code from $num too.
Leynos
on Nov 22, 2024
|
parent
[–]
Typeset num as an integer.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: