mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-05 13:31:15 -03:00
fix(echo): handle overflow in octal/hex escape parsing
Use wrapping arithmetic when parsing octal and hex escapes in echo to prevent panics on overflow and ensure consistent behavior with other shells. This change allows echo to process escape sequences like \5555 without crashing, keeping the same behavior as 3.7.1. ``` $ ./fish --version fish, version 3.7.1 $ ./fish -c 'echo -e "\5555"' m5 ```
This commit is contained in:
@@ -143,6 +143,11 @@ echo -e 'abc\121def'
|
||||
echo -e 'abc\1212def'
|
||||
#CHECK: abcQdef
|
||||
#CHECK: abcQ2def
|
||||
# Test octal overflow: \5555 = 555 octal = 365 decimal, wraps to 109 decimal (155 octal)
|
||||
# Followed by literal '5' character (065 octal)
|
||||
echo -ne '\5555' | display_bytes
|
||||
#CHECK: 0000000 155 065
|
||||
#CHECK: 0000002
|
||||
echo -e 'abc\cdef' # won't output a newline!
|
||||
#CHECK: abc
|
||||
echo ''
|
||||
|
||||
Reference in New Issue
Block a user