Skip to content

Commit

Permalink
Merge branch 'trunk' into news
Browse files Browse the repository at this point in the history
  • Loading branch information
magicant authored Feb 22, 2025
2 parents fe430f9 + 08ff38d commit 61ef507
Show file tree
Hide file tree
Showing 56 changed files with 1,725 additions and 366 deletions.
7 changes: 7 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
- The `trap` built-in now also reports signals that are ignored
because the program that invoked the shell has set the signal
to be ignored.
- The `wait` built-in no longer returns when the target process is
suspended if job-control is on. The built-in now waits for the
target process to exit or be terminated by a signal regardless
of mode.
- [line-editing] Updated the completion scripts to support Git
2.48.1.
- [line-editing] Added the completion script for `git-mv`.
- [line-editing] Added completion for bmake and gmake.
- Fixed a possible crash when the `read` built-in reads input in an
interactive shell.
Expand Down
5 changes: 5 additions & 0 deletions NEWS.ja
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
も含めて全てのトラップを表示する。
- `trap` 組込みはシェルが起動された時点で最初から無視されていた
シグナルも表示するようになった
- ジョブ制御が有効なとき `wait` 組込みはジョブが停止しても待機し
続けるようになった。これで、`wait` 組込みはモードに関係なく
ジョブが終了するまで待機するようになった
- [行編集] 補完スクリプトを Git 2.48.1 相当に更新
- [行編集] git-mv の補完を追加
- [行編集] bmake と gmake の補完を追加
- 対話シェルで `read` 組込みが入力を読み込む際にクラッシュすることが
あったのを修正
Expand Down
7 changes: 2 additions & 5 deletions doc/_wait.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@ The dfn:[wait built-in] waits for jobs to terminate.
== Description

The wait built-in waits for background jobs to terminate.
If link:job.html[job] control is enabled, stopped jobs are considered as
terminated.

The built-in can be used to wait for link:syntax.html#async[asynchronous
commands] if job control is disabled.
commands].

If the shell receives a signal while the built-in is waiting and if a
link:_trap.html[trap] has been set for the signal, then the trap is executed
and the built-in immediately finishes (without waiting for the jobs).
and the built-in immediately finishes (without further waiting for the jobs).
If the shell receives a SIGINT signal when job control is enabled, the
built-in aborts waiting.

Expand Down
3 changes: 1 addition & 2 deletions doc/ja/_wait.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ dfn:[Wait 組込みコマンド]はバックグラウンドの{zwsp}link:job.htm
[[description]]
== 説明

Wait コマンドは実行中のバックグラウンドジョブが終了するのを待ちます。{zwsp}link:job.html[ジョブ制御]が有効な時は、ジョブが停止したときも終了したとみなします。

Wait コマンドは実行中のバックグラウンドジョブが終了するのを待ちます。
Wait コマンドはジョブ制御が有効でないときでも{zwsp}link:syntax.html#async[非同期コマンド]の終了を待つのに使えます。

Wait コマンドの実行中にシェルがシグナルを受信した場合、そのシグナルに対し{zwsp}link:_trap.html[トラップ]が設定してあればそのトラップを直ちに実行し wait コマンドはそのまま終了します。またジョブ制御が有効な場合、シェルが SIGINT シグナルを受信すると wait コマンドは中断されます。
Expand Down
42 changes: 28 additions & 14 deletions job.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Yash: yet another shell */
/* job.c: job control */
/* (C) 2007-2024 magicant */
/* (C) 2007-2025 magicant */

/* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -1345,20 +1345,29 @@ int wait_for_job_by_jobspec(const wchar_t *jobspec)
|| job->j_legacy)
return Exit_NOTFOUND;

int signal = wait_for_job(jobnumber,
doing_job_control_now, doing_job_control_now, true);
if (signal != 0) {
assert(TERMSIGOFFSET >= 128);
return -(signal + TERMSIGOFFSET);
}
while (job->j_status != JS_DONE) {
bool savenonotify = job->j_nonotify;
job->j_nonotify = true;
int signal = wait_for_sigchld(
/* interruptible */ doing_job_control_now,
/* return_on_stop */ true);
job->j_nonotify = savenonotify;
if (signal != 0) {
assert(TERMSIGOFFSET >= 128);
return -(signal + TERMSIGOFFSET);
}

int status = calc_status_of_job(job);
if (job->j_status != JS_RUNNING) {
if (doing_job_control_now && is_interactive_now && !posixly_correct)
print_job_status(jobnumber, false, false, true, stdout);
else if (job->j_status == JS_DONE)
remove_job(jobnumber);
print_job_status(
jobnumber,
/* changedonly */ true,
/* verbose */ false,
/* remove_done */ false,
stdout);
}

int status = calc_status_of_job(job);
remove_job(jobnumber);
return status;
}

Expand All @@ -1369,15 +1378,20 @@ bool wait_builtin_has_job(bool jobcontrol)
for (size_t i = 1; i < joblist.length; i++) {
job_T *job = joblist.contents[i];
if (jobcontrol && is_interactive_now && !posixly_correct)
print_job_status(i, true, false, false, stdout);
print_job_status(
i,
/* changedonly */ true,
/* verbose */ false,
/* remove_done */ false,
stdout);
if (job != NULL && (job->j_legacy || job->j_status == JS_DONE))
remove_job(i);
}

/* see if we have jobs to wait for. */
for (size_t i = 1; i < joblist.length; i++) {
job_T *job = joblist.contents[i];
if (job != NULL && (!jobcontrol || job->j_status == JS_RUNNING))
if (job != NULL)
return true;
}
return false;
Expand Down
81 changes: 75 additions & 6 deletions share/completion/git
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
# (C) 2011-2021 magicant
# (C) 2011-2025 magicant

# Completion script for the "git" command.
# Supports Git 2.9.2.
# Supports Git 2.48.1.

function completion/git {

typeset OPTIONS ARGOPT PREFIX
OPTIONS=( #>#
"C:; specify a directory to operate in"
"c:; specify a configuration parameter"
"--attr-source:; specify the attribute file"
"--bare; treat the repository as a bare repository"
"--config-env:; specify a configuration parameter from environment"
"--exec-path::; specify or print the directory containing core git executables"
"--git-dir:; specify the repository directory"
"--glob-pathspecs; enable globbing on all path-specs"
"--html-path; print the directory where HTML documentation is installed"
"--icase-pathspecs; treat path-specs case-insensitively"
"--info-path; print the directory where info manuals are installed"
"--list-cmds:; list commands by group"
"--literal-pathspecs; treat path-specs literally"
"--man-path; print the directory where manual pages are installed"
"--namespace:; specify a namespace"
"--no-advice; don't print any hints"
"--noglob-pathspecs; disable globbing on all path-specs"
"--no-lazy-fetch; don't fetch missing objects from remote"
"--no-optional-locks; don't do optional operations that require locks"
"p --paginate; run a pager to view Git's output"
"--no-pager; don't run a pager to view Git's output"
"P --no-pager; don't run a pager to view Git's output"
"--no-replace-objects; don't use replacement refs"
"--work-tree:; specify the working tree directory"
"--help"
"--version"
"h --help"
"v --version"
) #<#

# convert "--help" to "help"
Expand Down Expand Up @@ -634,6 +640,14 @@ function completion/git::--author:arg {
done 2>/dev/null <(git log --all --format=format:%an | uniq)
}

function completion/git::--cleanup:arg { #>>#
complete -P "$PREFIX" -D "like \"strip\" when editing and \"whitespace\" otherwise" default
complete -P "$PREFIX" -D "delete empty lines and lines below the cut line" scissors
complete -P "$PREFIX" -D "delete empty lines and comments" strip
complete -P "$PREFIX" -D "leave message as is" verbatim
complete -P "$PREFIX" -D "delete empty lines" whitespace
} #<<#

function completion/git::--color:arg { #>>#
complete -P "$PREFIX" -D "always print in color" always
complete -P "$PREFIX" -D "print in color if output is terminal" auto
Expand All @@ -658,13 +672,38 @@ function completion/git::--date:arg { #>>#
complete -P "$PREFIX" -D "print in strict ISO 8601 format" iso8601-strict
complete -P "$PREFIX" -D "print in RFC 2822 format" rfc2822
complete -P "$PREFIX" -D "print in YYYY-MM-DD format" short
complete -P "$PREFIX" -D "print the raw timestamp value" raw
complete -P "$PREFIX" -D "print the raw timestamp value with offset" raw
complete -P "$PREFIX" -D "print in minimal human-readable format" human
complete -P "$PREFIX" -D "print the raw timestamp value" unix
complete -P "$PREFIX" local relative-local default-local iso8601-local \
iso8601-strict-local rfc2822-local short-local raw-local
complete -P "$PREFIX" -D "specify a format" -T format:
} #<<#
# TODO --date=format:...%

function completion/git::--empty:arg { #>>#
complete -P "$PREFIX" -D 'discard redundant patches' drop
complete -P "$PREFIX" -D 'create empty commits for redundant patches' keep
complete -P "$PREFIX" -D 'pause on redundant patches' stop
} #<<#

function completion/git::--exclude-hidden:arg { #>>#
complete -P "$PREFIX" -D "fetch.hideRefs" fetch
complete -P "$PREFIX" -D "receive.hideRefs" receive
complete -P "$PREFIX" -D "uploadpack.hideRefs" uploadpack
} #<<#

function completion/git::--filter:arg { #>>#
complete -P "$PREFIX" -D "omit all blobs" blob:none
complete -P "$PREFIX" -S = -T -D "pick blobs smaller than the specified size" blob:limit
complete -P "$PREFIX" -D "pick tags only" object:type=tag
complete -P "$PREFIX" -D "pick commits only" object:type=commit
complete -P "$PREFIX" -D "pick trees only" object:type=tree
complete -P "$PREFIX" -D "pick blobs only" object:type=blob
complete -P "$PREFIX" -S = -T -D "pick blobs for sparse checkout only" sparse:oid
complete -P "$PREFIX" -S : -T -D "omit blobs deeper than the specified level" tree
} #<<#

function completion/git::--format:arg {
typeset word="${TARGETWORD#"$PREFIX"}"
word=${word//%%}
Expand Down Expand Up @@ -721,6 +760,7 @@ function completion/git::--format:arg {
complete -P "$PREFIX" -D "commit ID, author, date, and full log message" medium
complete -P "$PREFIX" -D "commit ID, author, committer, and full log message" full
complete -P "$PREFIX" -D "commit ID, author, date, committer, date, and full log message" fuller
complete -P "$PREFIX" -D "commit ID, title, and date" reference
complete -P "$PREFIX" -D "imitate email" email
complete -P "$PREFIX" -D "raw commit object" raw
complete -P "$PREFIX" -D "specify a format (newline-separated)" -T format:
Expand All @@ -733,13 +773,21 @@ function completion/git::--format:arg {
esac
}

function completion/git::--gpg-sign:arg {
# TODO
}

function completion/git::--ignore-submodules:arg { #>>#
complete -P "$PREFIX" -D "ignore all changes in submodules" all
complete -P "$PREFIX" -D "ignore uncommitted changes in submodules" dirty
complete -P "$PREFIX" -D "show all changes in submodules" none
complete -P "$PREFIX" -D "ignore untracked files in submodules" untracked
} #<<#

function completion/git::--negotiation-tip:arg {
command -f completion/git::completeref
}

function completion/git::--pretty:arg {
command -f completion/git::--format:arg "$@"
}
Expand All @@ -755,6 +803,27 @@ function completion/git::--recurse-submodules:arg { #>>#
complete -P "$PREFIX" yes
} #<<#

function completion/git::--ref-format:arg { #>>#
complete -P "$PREFIX" files reftable
} #<<#

function completion/git::--refmap:arg {
command -f completion/git::completeref
}

function completion/git::--shallow-exclude:arg {
command -f completion/git::completeref
}

function completion/git::--sort:arg {
# TODO
}

function completion/git::--track:arg { #>>#
complete -P "$PREFIX" -D "use start-point branch as upstream" direct
complete -P "$PREFIX" -D "copy remote-tracking branch from start-point branch" inherit
} #<<#

function completion/git::--untracked-files:arg { #>>#
complete -P "$PREFIX" -D "print all individual files in untracked directories" all
complete -P "$PREFIX" -D "print untracked files and directories" normal
Expand Down
17 changes: 15 additions & 2 deletions share/completion/git-add
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# (C) 2011-2013 magicant
# (C) 2011-2025 magicant

# Completion script for the "git-add" command.
# Supports Git 1.7.7.
# Supports Git 2.48.1

function completion/git-add {
WORDS=(git add "${WORDS[2,-1]}")
Expand All @@ -12,15 +12,22 @@ function completion/git::add:arg {

OPTIONS=( #>#
"A --all; add all files including untracked files"
"--chmod:; override executable bit of added files"
"n --dry-run; don't actually add files"
"e --edit; edit patch hunks before adding"
"f --force; add ignored files"
"--ignore-errors; continue adding other files on an error"
"--ignore-missing; ignore missing files (with -n)"
"N --intent-to-add; add filepaths but not their contents"
"i --interactive; enter the interactive mode"
"--no-all --no-ignore-removal; add only new and modified files"
"--no-warn-embedded-repo; allow adding embedded repositories"
"p --patch; interactively choose patch hunks to add"
"--pathspec-file-nul; use nul as separator for pathspecs"
"--pathspec-from-file:; read pathspecs from file"
"--refresh; refresh stat info in the index without adding"
"--renormalize; re-apply \"clean\" process"
"--sparse; update index outside of sparse-checkout cone"
"u --update; add tracked files only; don't add new files"
"v --verbose; print affected filenames"
) #<#
Expand All @@ -30,6 +37,12 @@ function completion/git::add:arg {
(-)
command -f completion//completeoptions
;;
(--chmod)
complete -P "$PREFIX" -- -x +x
;;
(--pathspec-from-file)
complete -P "$PREFIX" -f
;;
('')
command -f completion/git::add:opr
;;
Expand Down
28 changes: 25 additions & 3 deletions share/completion/git-am
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# (C) 2011 magicant
# (C) 2011-2025 magicant

# Completion script for the "git-am" command.
# Supports Git 1.7.7.
# Supports Git 2.48.1.

function completion/git-am {
WORDS=(git am "${WORDS[2,-1]}")
Expand All @@ -11,20 +11,33 @@ function completion/git-am {
function completion/git::am:arg {

OPTIONS=( #>#
"3 --3way; try 3-way merge on conflict"
"--allow-empty; create empty commit for message without patch"
"--abort; abort patching and restore the original branch"
"--committer-date-is-author-date; use author date for committer date"
"r --continue --resolved; commit the current index and continue patching"
"--empty:; specify how to handle messages without a patch"
"S:: --gpg-sign::; sign commits using GPG"
"--ignore-date; use committer date for author date"
"i --interactive"
"k --keep; use the mail subject intact as the commit message"
"--keep-cr; don't remove carriage returns at the end of lines"
"--keep-non-patch; keep bracketed words in subject except [PATCH]"
"m --message-id; add message-id to commit message"
"--no-3way; don't try 3-way merge on conflict"
"--no-gpg-sign; don't sign commits using GPG"
"--no-keep-cr; remove carriage returns at the end of lines"
"--no-message-id; don't add message-id to commit message"
"--no-scissors; cancels the --scissors OPTIONS"
"--no-utf8; don't convert character encoding"
"v --no-verify; bypass pre-applypatch and applypatch-msg hooks"
"--patch-format:; specify patch format"
"--quoted-cr:; specify how to handle CR in quoted email"
"q --quiet; print error messages only"
"--quit; abort patching and keep HEAD and index as is"
"--resolvemsg:" # not for command line use
"--retry; re-apply last conflicting patch"
"c --scissors; remove lines before a scissors line"
"--show-current-patch::; show message on conflict"
"s --signoff; add a \"signed-off-by\" line to the message"
"--skip; skip the current patch (when restarting an aborted patch)"
"u --utf8; re-encode the log message into UTF-8"
Expand All @@ -42,6 +55,15 @@ function completion/git::am:arg {
('')
complete -P "$PREFIX" -f
;;
(--empty)
command -f completion/git::--empty:arg
;;
(--patch-format)
complete -P "$PREFIX" mbox mboxrd stgit stgit-series hg
;;
(S|--gpg-sign)
command -f completion/git::--gpg-sign:arg
;;
(*)
if command -vf completion/git::apply:compopt >/dev/null 2>&1 ||
. -AL completion/git-apply; then
Expand Down
2 changes: 1 addition & 1 deletion share/completion/git-annotate
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# (C) 2011 magicant

# Completion script for the "git-annotate" command.
# Supports Git 1.7.7.
# Supports Git 2.48.1.

function completion/git-annotate {
WORDS=(git annotate "${WORDS[2,-1]}")
Expand Down
Loading

0 comments on commit 61ef507

Please sign in to comment.