简体   繁体   中英

/bin/sh does not recognize hexadecimal escape sequences

Why this happens on /bin/bash:

$ printf '%b' '\x90'
?
$

But this happens on /bin/sh:

$ printf '%b' '\x90'
\x90
$

Which difference between /bin/bash and /bin/sh and why first decodes hex and the second can't?

Because escape sequences in \xdd form (where each d represents a hexadecimal digit) are a GNU extension and not available everywhere. But octals are widely supported (and standardized ), so you can use:

printf '%b' '\0220'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM