Skip to content
Merged
Changes from 2 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
7 changes: 4 additions & 3 deletions completions-core/sudo.bash
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ _comp_cmd_sudo()
break
fi
# shellcheck disable=SC2254
[[ ${words[i]} == @(--@(close-from|chdir|group|host|prompt|chroot|role|command-timeout|type|other-user|user)|-${noargopts}[CDghpRrTtUu]) ]] &&
[[ ${words[i]} == @(--@(close-from|chdir|group|host|prompt|chroot|role|command-timeout|type|other-user|user|preserve-env)|-${noargopts}[CDghpRrTtUu]) ]] &&

@akinomyoga akinomyoga Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the ordering of the list of the long option names is roughly based on the ordering in the man page. Then, I think preserve-env should be inserted after chdir (based on the man page in sudo-1.9.15p5). For the same reason, I think command-timeout should be moved after other-user (or after type if one bases on sudo --help instead of the man page). Another option is to sort them in lexicographical order.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not compared the two, but the ordering seemed to be roughly that of the --help output, and --preserve-end is at the end with sudo-rs so it ended up there.

Reordered all of them in 80156e3, merging with that.

((i++))
done

Expand All @@ -37,8 +37,9 @@ _comp_cmd_sudo()
_comp_compgen -- -g
return
;;
--close-from | --prompt | --role | --type | --command-timeout | \
-${noargopts}[CprTt])
--close-from | --help | --prompt | --role | --type | \
--command-timeout | --preserve-env | --version | \

@akinomyoga akinomyoga Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, --preserve-env should be inserted after --close-from.

-${noargopts}[CprTtV]) # no "h", sudo.ws treats it as host with arg
return
;;
--chdir | --chroot | -${noargopts}[DR])
Expand Down