Skip to content

Commit

Permalink
edit (display-shell-version): support running as a user command
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Nov 28, 2022
1 parent 43c6d4b commit e618133
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 24 deletions.
5 changes: 3 additions & 2 deletions .github/ISSUE_TEMPLATE/00_T1-bug_report.md
Expand Up @@ -6,8 +6,9 @@ about: Create a report to fix problems

**ble version**: <!-- The version and commit-hash or the result of `echo "$BLE_VERSION"` -->
**Bash version**: <!-- The result of `echo "$BASH_VERSION ($MACHTYPE)"` -->
<!-- You can instead copy and paste the result of pressing [Ctrl-x][Ctrl-v] in
the ble.sh session. -->
<!-- Instead of the above, you can copy and paste the result of running the
command "ble/widget/display-shell-version" or the result of pressing
[Ctrl-x][Ctrl-v] in a ble.sh session with the issue. -->

<!-- Describe the problem here. If example terminal contents (in either the
text form or an image) are available, you may paste/insert them to explain
Expand Down
5 changes: 3 additions & 2 deletions .github/ISSUE_TEMPLATE/01_T1-bug_report.md
Expand Up @@ -6,8 +6,9 @@ about: 問題報告ありがとうございます! どんなに些細なこと

**ble version**: <!-- ble.sh をロードした上で `echo $BLE_VERSION` で確認できる値。または ble のバージョン及びコミットハッシュ -->
**Bash version**: <!-- `echo "$BASH_VERSION ($MACHTYPE)"` で確認できる値。または Bash のバージョン及び環境 -->
<!-- 以上の情報の代わりに、ble.sh をロードした状態で [Ctrl-x][Ctrl-v] を押した
結果をコピー・貼り付けしていただく事も可能です。 -->
<!-- 以上の情報の代わりに、問題の発生する ble.sh をロードした状態で、コマンド
"ble/widget/display-shell-version" を実行した結果、または [Ctrl-x][Ctrl-v] を
押した結果をコピー・貼り付けしていただく事も可能です。 -->

<!--- 問題についてここに自由に記述して下さって差し支えありません! 不明な点があ
ればまたこちらからお尋ねしますのでご安心下さいませ。もし問題の発生している端
Expand Down
16 changes: 13 additions & 3 deletions GNUmakefile
Expand Up @@ -10,12 +10,18 @@ endif

# check gawk
GAWK := $(shell which gawk 2>/dev/null || type -p gawk 2>/dev/null)
ifeq ($(GAWK),)
ifneq ($(GAWK),)
GAWK_VERSION := $(shell LANG=C $(GAWK) --version 2>/dev/null | head -1 | grep -Fi 'GNU Awk')
ifeq ($(GAWK_VERSION),)
$(error Sorry, gawk is found but does not seem to work. Please install a proper version of gawk (GNU Awk).)
endif
else
GAWK := $(shell which awk 2>/dev/null || type -p awk 2>/dev/null)
ifeq ($(GAWK),)
$(error Sorry, gawk/awk could not be found. Please check your PATH environment variable.)
endif
ifeq ($(shell $(GAWK) --version 2>/dev/null | grep -Fi 'GNU Awk'),)
GAWK_VERSION := $(shell LANG=C $(GAWK) --version 2>/dev/null | head -1 | grep -Fi 'GNU Awk')
ifeq ($(GAWK_VERSION),)
$(error Sorry, gawk could not be found. Please install gawk (GNU Awk).)
endif
endif
Expand All @@ -38,7 +44,11 @@ ble-form.sh:
outfiles+=$(OUTDIR)/ble.sh
-include $(OUTDIR)/ble.dep
$(OUTDIR)/ble.sh: ble.pp GNUmakefile | .git $(OUTDIR)
DEPENDENCIES_PHONY=1 DEPENDENCIES_OUTPUT=$(@:%.sh=%.dep) DEPENDENCIES_TARGET=$@ FULLVER=$(FULLVER) \
DEPENDENCIES_PHONY=1 DEPENDENCIES_OUTPUT="$(@:%.sh=%.dep)" DEPENDENCIES_TARGET="$@" \
FULLVER=$(FULLVER) \
BUILD_GIT_VERSION="$(shell LANG=C git --version)" \
BUILD_MAKE_VERSION="$(shell LANG=C $(MAKE) --version | head -1)" \
BUILD_GAWK_VERSION="$(GAWK_VERSION)" \
$(MWGPP) $< >/dev/null
.DELETE_ON_ERROR: $(OUTDIR)/ble.sh

Expand Down
3 changes: 3 additions & 0 deletions ble.pp
Expand Up @@ -1518,6 +1518,9 @@ function ble-reload {
#%$ pwd=$(pwd) q=\' Q="'\''" bash -c 'echo "_ble_base_repository=$q${pwd//$q/$Q}$q"'
#%$ echo "_ble_base_branch=$(git rev-parse --abbrev-ref HEAD)"
_ble_base_repository_url=https://github.com/akinomyoga/ble.sh
#%$ echo "_ble_base_build_git_version=\"$BUILD_GIT_VERSION\""
#%$ echo "_ble_base_build_make_version=\"$BUILD_MAKE_VERSION\""
#%$ echo "_ble_base_build_gawk_version=\"$BUILD_GAWK_VERSION\""
function ble-update/.check-install-directory-ownership {
if [[ ! -O $_ble_base ]]; then
ble/util/print 'ble-update: install directory is owned by another user:' >&2
Expand Down
4 changes: 3 additions & 1 deletion docs/ChangeLog.md
Expand Up @@ -201,6 +201,8 @@
- prompt: preserve transient prompt with `same-dir` after `clear-screen` `#D1876` 69013d9
- color: let `bleopt term_index_colors` override the default if specified `#D1878` 7d238c0
- canvas: update Unicode version 15.0.0 `#D1880` 49e55f4
- edit (`display-shell-version`): show `gawk`, `make`, and `git` versions of the build time `#D1892`
- edit (`display-shell-version`): support running as a user command (reported by DhruvaG2000) `#D1893`

## Fixes

Expand Down Expand Up @@ -484,7 +486,7 @@
- make: check necessary `.git` `#D1887` 0f7c04b
- benchmark (zsh): fix for `KSH_ARRAYS` `#D1886` a144ffa 8cb9b84
- benchmark: support for ksh as `benchmark.ksh` `#D1886` 5dae4da
- github/workflows (build): rename directory in `ble-nightly.tar.xz` to `ble-nightly` (reported by Harduex) `#D1891` xxxxxxx
- github/workflows (build): rename directory in `ble-nightly.tar.xz` to `ble-nightly` (reported by Harduex) `#D1891` f20854f 4ea2e23 43c6d4b

## Contrib

Expand Down
34 changes: 21 additions & 13 deletions note.txt
Expand Up @@ -1855,19 +1855,6 @@ bash_tips
- leakvars
- keymap の移動 (これは別 commit にする?)

2022-10-28

* edit: display-shell-version
https://github.com/akinomyoga/ble.sh/issues/246#issuecomment-1294843777

直接 ble/widget/display-shell-version を実行すれば良い。
C-x C-v が効かない端末でもOK

* edit: display-shell-version
https://github.com/akinomyoga/ble.sh/issues/246#issuecomment-1294893636

git, gmake 及び gawk の version も表示する?

2022-10-24

* rename blerc.template
Expand Down Expand Up @@ -6640,6 +6627,27 @@ bash_tips

2022-11-28

* 2022-10-28 edit: display-shell-version を直接実行できる様にする (reported by DhruvaG2000) [#D1893]
https://github.com/akinomyoga/ble.sh/issues/246#issuecomment-1294843777

直接 ble/widget/display-shell-version を実行すれば良い。C-x C-v が
効かない端末でもOK。例えば報告者の環境では C-v が「貼り付け」に奪
われていた。

* done: 直接実行しても表示が壊れない様に ble/widget/print を修正した。
* done: issue template を修正した。
* reject: wiki に関しては確認してみたがそもそも C-x C-v の指示も書
いていなかった。敢えてここで新しく解説を追加する必要もない気がす
る。

* 2022-10-28 edit: display-shell-version で git/gmake/gawk の情報を表示 [#D1892]
https://github.com/akinomyoga/ble.sh/issues/246#issuecomment-1294893636

git, gmake 及び gawk の version も表示する? 変な生成のされ方をして
いないか確認する時にこの情報があった方が良い。

これは生成に用いた物の version なので生成時に埋め込むべきの気がする。

* 2022-10-13 github/workflows について (reported by Harduex) [#D1891]
https://github.com/akinomyoga/ble.sh/pull/240

Expand Down
12 changes: 9 additions & 3 deletions src/edit.sh
Expand Up @@ -3827,7 +3827,8 @@ function ble/widget/display-shell-version {
fi

local lines="${sgrC}GNU bash$sgr0, version $sgrV$BASH_VERSION$sgr0 ($sgrA$MACHTYPE$sgr0)${os_release:+ [$os_release]}" iline=1
lines[iline++]="${sgrF}ble.sh$sgr0, version $sgrV$BLE_VERSION$sgr0$label_noarch"
local ble_build_info="${_ble_base_build_git_version/#git version/git}, $_ble_base_build_make_version, $_ble_base_build_gawk_version"
lines[iline++]="${sgrF}ble.sh$sgr0, version $sgrV$BLE_VERSION$sgr0$label_noarch [$ble_build_info]"

ble/edit/display-version/check:bash-completion
ble/edit/display-version/check:fzf
Expand Down Expand Up @@ -10015,8 +10016,13 @@ function ble/widget/print {
local message="$*" lines
[[ ${message//["$_ble_term_IFS"]} ]] || return 1
lines=("$@")
ble/widget/.internal-print-command \
'ble/util/print-lines "${lines[@]}" >&2' pre-flush

if [[ ! ${_ble_attached-} || ${_ble_edit_exec_inside_begin-} ]]; then
ble/util/print-lines "${lines[@]}"
else
ble/widget/.internal-print-command \
'ble/util/print-lines "${lines[@]}" >&2' pre-flush
fi
}
function ble/widget/internal-command {
ble-edit/content/clear-arg
Expand Down

0 comments on commit e618133

Please sign in to comment.