Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Acme.Sh
Commits
9bdb799b
Commit
9bdb799b
authored
Feb 05, 2017
by
neilpang
Browse files
fix bug when the od command is missing
parent
259cefab
Changes
1
Hide whitespace changes
Inline
Side-by-side
acme.sh
View file @
9bdb799b
...
...
@@ -340,11 +340,29 @@ _is_solaris() {
_contains
"
${
__OS__
:
=
$(
uname
-a
)
}
"
"solaris"
||
_contains
"
${
__OS__
:
=
$(
uname
-a
)
}
"
"SunOS"
}
#_ascii_hex str
#this can only process ascii chars, should only be used when od command is missing as a backup way.
_ascii_hex
()
{
_debug2
"Using _ascii_hex"
_str
=
"
$1
"
_str_len
=
${#
_str
}
_h_i
=
1
while
[
"
$_h_i
"
-le
"
$_str_len
"
]
;
do
_str_c
=
"
$(
printf
"%s"
"
$_str
"
|
cut
-c
"
$_h_i
"
)
"
printf
" %02x"
"'
$_str_c
"
_h_i
=
"
$(
_math
"
$_h_i
"
+ 1
)
"
done
}
#stdin output hexstr splited by one space
#input:"abc"
#output: " 61 62 63"
_hex_dump
()
{
od
-A
n
-v
-t
x1 |
tr
-d
"
\r\t
"
|
tr
-s
" "
|
sed
"s/
$/
/"
|
tr
-d
"
\n
"
#in wired some system, the od command is missing.
if
!
od
-A
n
-v
-t
x1 |
tr
-d
"
\r\t
"
|
tr
-s
" "
|
sed
"s/
$/
/"
|
tr
-d
"
\n
"
2>/dev/null
;
then
str
=
$(
cat
)
_ascii_hex
"
$str
"
fi
}
#url encode, no-preserved chars
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment