test: Added error handling to hex_to_rgb

This commit is contained in:
Dylan Araps
2018-06-23 09:51:39 +10:00
parent cf243bc86b
commit 809c8b5a03
2 changed files with 8 additions and 7 deletions

View File

@@ -1585,10 +1585,8 @@ $ get_cursor_pos
```sh
hex_to_rgb() {
# Usage: hex_to_rgb "#FFFFFF"
((r=16#${1:1:2}))
((g=16#${1:3:2}))
((b=16#${1:5:6}))
: "${1/\#}"
((r=16#${_:0:2},g=16#${_:2:2},b=16#${_:4:2}))
printf '%s\n' "$r $g $b"
}
```