Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sed regex on OSX #94

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions resty
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ HELP
if [[ "POST PUT TRACE PATCH DELETE" =~ $method ]]; then local hasbody; hasbody="yes" ;fi

if [ -d "$cookies" ] ; then # retrieve cookie
(mkdir -p "$cookies"; echo "http://localhost*" > "$host")
(mkdir -p "$cookies"; echo "http://localhost*" >| "$host")
fi

if [[ "$1" =~ ^/ ]] ; then # retrieve path
Expand All @@ -143,7 +143,7 @@ HELP
[[ $# -gt 0 ]] && shift
fi

local -a all_opts curlopt_cmd
local -a all_opts curl_opt curlopt_cmd
local raw query vimedit quote maybe_query verbose dry_run

local -a resty_default_arg host_arg;
Expand Down Expand Up @@ -199,7 +199,7 @@ HELP

if [ "$hasbody" = "yes" ] && [ "$vimedit" = "yes" ]; then
local tmpf; tmpf=$(mktemp)
[ -t 0 ] || cat > "$tmpf"
[ -t 0 ] || cat >| "$tmpf"
(exec < /dev/tty; "$editor" "$tmpf")
body=$(cat "$tmpf")
rm -f "$tmpf"
Expand All @@ -224,9 +224,9 @@ HELP
# Launch command and retrieved streams
local res out err ret _status outf errf
outf=$(mktemp) errf=$(mktemp)
eval "${cmd[@]}" > "$outf" 2> "$errf"
eval "${cmd[@]}" >| "$outf" 2>| "$errf"
_status=$?; out="$(cat "$outf")"; err="$(cat "$errf")"; rm -f "$outf" "$errf"
ret=$(sed '/^.*HTTP\/1\.[01] [0-9][0-9][0-9]/s/.*\([0-9]\)[0-9][0-9].*/\1/p; d' <<< "$err" | tail -n1)
ret=$(sed '/^.*HTTP\/[12].*/s/.* \([0-9]\)[0-9][0-9].*/\1/p; d' <<< "$err" | tail -n1)

if [ "$_status" -ne "0" ]; then echo "$err" >&2 ; return $_status ; fi

Expand Down