Skip to main content
6 events
when toggle format what by license comment
Oct 7, 2023 at 6:57 comment added Stéphane Chazelas Never use [[...]]'s arithmetic operators nor ((...)) for input validation as that introduces command injection vulnerabilities. For instance with ch='a[$(reboot)]', that would reboot.
Oct 7, 2023 at 6:53 comment added Stéphane Chazelas Depending on the system and locale, regexp [0-5] may match dozens of different characters that happen to sort in-between 0 and 5. Such as ², ³ or decimal digits in other scripts. Use [012345] if you only want to match on the arabic digits
Oct 7, 2023 at 1:53 comment added preetam try this: ch=44;nums=6;[[ $ch -gt 0 && $ch < $nums ]] && echo "ok" || echo "no" Doesn't work.
Oct 7, 2023 at 1:06 comment added jesse_b @preetam if ch is not a number it will fail those checks just like it would the regex test
Oct 7, 2023 at 1:05 comment added preetam But I also want to check for if input is number as well as range in one regex.
Oct 7, 2023 at 0:57 history answered jesse_b CC BY-SA 4.0