Skip to content

Commit

Permalink
global: quote return $?
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Oct 1, 2022
1 parent b76e21e commit 801d14a
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 26 deletions.
14 changes: 7 additions & 7 deletions ble.pp
Expand Up @@ -1552,7 +1552,7 @@ function ble-update/.reload {
elif [[ $- == *i* && $_ble_attached ]] && ! ble/util/is-running-in-subshell; then
ble-reload
fi
return $?
return "$?"
fi
((ext==6)) && ext=0
return "$ext"
Expand All @@ -1571,7 +1571,7 @@ function ble-update/.download-nightly-build {
# _ble_base が自分の物でない時は sudo でやり直す
sudo "$BASH" "$_ble_base/ble.sh" --update &&
ble-update/.reload 6
return $?
return "$?"
fi

local tarname=ble-nightly.tar.xz
Expand Down Expand Up @@ -1660,7 +1660,7 @@ function ble-update {
ble/util/print 'ble-update: fallback to the default update process.' >&2
else
ble-update/.reload "$ext"
return $?
return "$?"
fi
fi

Expand Down Expand Up @@ -1721,16 +1721,16 @@ function ble-update {
else
ble-update/.make INSDIR="$_ble_base" INSDIR_DOC="$insdir_doc" install
fi )
ble-update/.reload $?
return $?
ble-update/.reload "$?"
return "$?"
fi
fi

if ((EUID!=0)) && ! ble-update/.check-install-directory-ownership; then
# _ble_base が自分の物でない時は sudo でやり直す
sudo "$BASH" "$_ble_base/ble.sh" --update &&
ble-update/.reload 6
return $?
return "$?"
else
# _ble_base/src 内部に clone して make install
local branch=${_ble_base_branch:-master}
Expand Down Expand Up @@ -1819,7 +1819,7 @@ function ble/dispatch/.help {
function ble/dispatch {
if (($#==0)); then
[[ $_ble_attached && ! $_ble_edit_exec_inside_userspace ]]
return $?
return "$?"
fi

# import autoload measure assert stackdump color-show decode-{byte,char,key}
Expand Down
2 changes: 1 addition & 1 deletion contrib
Submodule contrib updated 1 files
+74 −16 prompt-git.bash
1 change: 1 addition & 0 deletions docs/ChangeLog.md
Expand Up @@ -312,6 +312,7 @@
- main (`ble-update`): fix error message with system-wide installation of `ble.sh` (fixed by tars0x9752) 1d2a9c1 a450775
- main. util: fix problems of readlink etc. found by test in macOS (reported by aiotter) `#D1849` fa955c1 `#D1855` a22e145
- progcomp: fix a bug that `COMP_WORDBREAKS` is ignored `#D1872` 4d2dd35
- global: quote `return $?` `#D1884` xxxxxxx

## Documentation

Expand Down
2 changes: 1 addition & 1 deletion lib/core-complete-def.sh
Expand Up @@ -23,7 +23,7 @@ function ble-sabbrev {
done
if (($#==0)) || [[ $print ]]; then
ble-import lib/core-complete && ble-sabbrev "$@"
return $?
return "$?"
fi

local ret; ble/string#quote-command "$FUNCNAME" "$@"
Expand Down
4 changes: 2 additions & 2 deletions lib/core-complete.sh
Expand Up @@ -1519,7 +1519,7 @@ function ble/complete/action/quote-insert.batch {
else
ble/util/assign-array inserts ble/complete/action/quote-insert.batch/proc
fi
return $?
return "$?"
}

function ble/complete/action/requote-final-insert {
Expand Down Expand Up @@ -3818,7 +3818,7 @@ function ble/complete/progcomp {
ble/complete/progcomp "${comp_words[0]}" "__recursive__:$opts"
fi
fi
return $?
return "$?"
fi

[[ $alias_checked != *" $ret "* ]] || break
Expand Down
4 changes: 2 additions & 2 deletions lib/core-syntax.sh
Expand Up @@ -6644,7 +6644,7 @@ function ble/progcolor/is-option-context {
if [[ ${progcolor_optctx[1]} ]]; then
# Note: 等号は停止を引き起こした引数 -- 自体の時 (オプションとして有効)
((progcolor_optctx[1]<0?1:(progcolor_iword<=progcolor_optctx[1])))
return $?
return "$?"
fi

local rexrej rexreq stopat
Expand All @@ -6656,7 +6656,7 @@ function ble/progcolor/is-option-context {
if [[ ! $rexrej$rexreq ]]; then
progcolor_optctx[1]=${stopat:--1}
((progcolor_optctx[1]<0?1:(progcolor_iword<=progcolor_optctx[1])))
return $?
return "$?"
fi
progcolor_optctx[2]=$rexrej
progcolor_optctx[3]=$rexreq
Expand Down
3 changes: 2 additions & 1 deletion make_command.sh
Expand Up @@ -1288,14 +1288,15 @@ function sub:scan/word-splitting-number {
echo "--- $FUNCNAME ---"
# #D1835 一般には IFS に整数が含まれるている場合もあるので ${#...} や
# $((...)) や >&$fd であってもちゃんと quote する必要がある。
grc '[<>]&\$|([[:space:]]|=\()\$(\(\(|\{#)' --exclude={docs,mwg_pp.awk} |
grc '[<>]&\$|([[:space:]]|=\()\$(\(\(|\{#|\?)' --exclude={docs,mwg_pp.awk} |
sed -E 'h;s/'"$esc"'//g;s/^[^:]*:[0-9]+:[[:space:]]*//
\Z^[^#]*(^|[[:space:]])#Zd
\Z^([^"]|"[^\#]*")*"[^"]*([& (]\$)Zd
\Z^[^][]*\[\[[^][]*([& (]\$)Zd
\Z\(\([a-zA-Z_0-9]+=\(\$Zd
\Z\$\{#[a-zA-Z_0-9]+\}[<>?&]Zd
\Z \$\{\#[a-zA-Z_0-9]+\[@\]\} -gt 0 \]\]Zd
\Zcase \$\? inZd
g'
}

Expand Down
17 changes: 17 additions & 0 deletions note.txt
Expand Up @@ -6604,6 +6604,23 @@ bash_tips
Done (実装ログ)
-------------------------------------------------------------------------------

2022-09-26

* 2022-09-23 prompt-git: rebase や merge 等の状態を表示したい [#D1884]

色々方法は考えられるがどうやら git-prompt.sh の __git_ps1 で使われている判定方法を用いれば良いらしい。
https://stackoverflow.com/questions/30733415/how-to-determine-if-git-merge-is-in-process
https://stackoverflow.com/questions/3921409/how-to-know-if-there-is-a-git-rebase-in-progress
https://stackoverflow.com/a/3922581/4908404

取り敢えず以下を元にした実装にする。
https://github.com/git/git/blob/4fd6c5e44459e6444c2cd93383660134c95aabd1/contrib/completion/git-prompt.sh#L452-L475

* global: return $? IFS [#D1883]

未だ残っている? もしくは新しく増えた物かもしれない。修正する。
make scan でも $? を検索する様に変更する。

2022-09-25

* test: sha256sum がないというエラー @ macOS [#D1882]
Expand Down
6 changes: 3 additions & 3 deletions src/canvas.sh
Expand Up @@ -2240,7 +2240,7 @@ function ble/canvas/trace-text/.put-simple {
out=$out${2::nput}
((x+=nput,y+=x/cols,x%=cols))
((_ble_term_xenl&&x==0&&(y--,x=cols)))
((nput==nchar)); return $?
((nput==nchar)); return "$?"
}
## @fn x y cols out ; ble/canvas/trace-text/.put-atomic ( w char )+ ; x y out
## 指定した文字を out に追加しつつ、現在位置を更新します。
Expand Down Expand Up @@ -2273,7 +2273,7 @@ function ble/canvas/trace-text/.put-atomic {
local pad=${_ble_string_prototype::limit-x}
out=$out$sgr1${pad//?/'#'}$sgr0
x=$limit
((y+1<lines)); return $?
((y+1<lines)); return "$?"
fi

out=$out$c
Expand Down Expand Up @@ -3193,7 +3193,7 @@ function ble/canvas/panel#set-height.draw {
if ((delta==0)); then
if [[ :$opts: == *:clear:* ]]; then
ble/canvas/panel#clear.draw "$index"
return $?
return "$?"
else
return 1
fi
Expand Down
16 changes: 8 additions & 8 deletions src/edit.sh
Expand Up @@ -1713,10 +1713,10 @@ function ble/prompt/update {
ble/prompt/unit#update _ble_prompt_ps1 && dirty=1

# Note #D1392: mc (midnight commander) の中では補助プロンプトは全て off
[[ $MC_SID == $$ ]] && { [[ $dirty ]]; return $?; }
[[ $MC_SID == $$ ]] && { [[ $dirty ]]; return "$?"; }

# Note: 補助プロンプトは _ble_textarea_panel==0 の時だけ有効 #D1027
((_ble_textarea_panel==0)) || { [[ $dirty ]]; return $?; }
((_ble_textarea_panel==0)) || { [[ $dirty ]]; return "$?"; }

# bleopt prompt_rps1
if [[ :$opts: == *:leave:* && ! $rps1f && $bleopt_prompt_rps1_transient ]]; then
Expand Down Expand Up @@ -3575,7 +3575,7 @@ function ble/edit/display-version/git-rev-parse {
fi
ret=$content
[[ $ret ]]
return $?
return "$?"
fi
return 1
}
Expand Down Expand Up @@ -5779,7 +5779,7 @@ function ble/builtin/exit {
if [[ ! $_ble_builtin_trap_processing ]] && { ble/util/is-running-in-subshell || [[ $_ble_decode_bind_state == none ]]; }; then
(($#)) || set -- "$ext"
builtin exit "$@"
return $? # オプションの指定間違いなどで失敗する可能性がある。
return "$?" # オプションの指定間違いなどで失敗する可能性がある。
fi

local set shopt; ble/base/.adjust-bash-options set shopt
Expand Down Expand Up @@ -6695,12 +6695,12 @@ function ble-edit/exec:gexec/.setup {
fi

# コマンド実行をする場合は ble-edit/bind/.tail は遅延する
((count>=1)); return $?
((count>=1)); return "$?"
}

function ble-edit/exec:gexec/process {
ble-edit/exec:gexec/.setup
return $?
return "$?"
}
function ble-edit/exec:gexec/restore-state {
# 構文エラー等で epilogue/end が呼び出されなかった時の為 #D1170
Expand Down Expand Up @@ -8629,7 +8629,7 @@ function ble/widget/history-search {
else
ble/widget/history-prev
fi && _ble_edit_ind=0
return $? ;;
return "$?" ;;
(hide-status)
opts=$opts:hide-status ;;
(emulate-readline)
Expand Down Expand Up @@ -9916,7 +9916,7 @@ function ble-edit/bind/.check-detach {
if ! ble/decode/attach; then
ble-detach
ble-edit/bind/.check-detach # 改めて終了処理
return $?
return "$?"
fi
fi

Expand Down
2 changes: 1 addition & 1 deletion src/util.sh
Expand Up @@ -1639,7 +1639,7 @@ fi

function ble/util/copyfile {
local src=$1 dst=$2 content
ble/util/readfile content "$1" || return $?
ble/util/readfile content "$1" || return "$?"
ble/util/put "$content" >| "$dst"
}

Expand Down

0 comments on commit 801d14a

Please sign in to comment.