diff --git a/resty b/resty index 3b6368f..b3ddbde 100644 --- a/resty +++ b/resty @@ -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 @@ -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; @@ -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" @@ -213,8 +213,7 @@ HELP fi # Forge command and display it if dry-run - local cmd - cmd=(curl -sLv $curl_opt $(printf "%q" "$body") -X $method -b \"$cookies/$domain\" -c \"$cookies/$domain\" "$(\ + local cmd=(curl -sLv $curl_opt $(printf "%q" "$body") -X $method -b \"$cookies/$domain\" -c \"$cookies/$domain\" "$(\ [ -n "$curlopt_cmd" ] && printf '%s ' ${curlopt_cmd[@]})"\"$_path$query\") if [ "$dry_run" = "yes" ] ; then echo "${cmd[@]}" @@ -224,9 +223,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]\(\.[01]\)\? [0-9][0-9][0-9]/s/.*\([0-9]\)[0-9][0-9].*/\1/p; d' <<< "$err" | tail -n1) if [ "$_status" -ne "0" ]; then echo "$err" >&2 ; return $_status ; fi @@ -337,4 +336,4 @@ HELP # With -W option, does not write to history file [ "$1" = "-W" ] && export _RESTY_NO_HISTORY="/dev/null" && [[ $# -gt 0 ]] && shift -resty "$@" >/dev/null 2>&1 +resty "$@" >/dev/null 2>&1 \ No newline at end of file