From 728a5f14b5307f8916f3e17f75ce7956b0680ab8 Mon Sep 17 00:00:00 2001 From: cubernetes Date: Thu, 15 Oct 2026 10:49:38 +0200 Subject: [PATCH] Use #-# style comments --- bashrc-forward.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bashrc-forward.sh b/bashrc-forward.sh index a3cdd95..9978125 100644 --- a/bashrc-forward.sh +++ b/bashrc-forward.sh @@ -165,13 +165,13 @@ bashrc_forward () { ' } -# HARD TO FIX BUG: shopt -u expand_aliases must be run in ENV so bash-abbr works, but ENV is run before the shell switches to interactive -# use, and --rcfile is run after. We need to disable expand_aliases AFTER the shell switches to interactive mode, because on that switch -# alias expansion is always turned on. You'd think you could use a trap, PROMPT_COMMAND, or bind -x trick for that, but no, there's a bug -# currently in bash that prevents exactly that. The only workaround at the moment is to create a custom binding that injects the -# shopt -u expand_aliases command ONCE before the very first command. -# When bash finally fixes that trap bug, then we don't need to do that anymore. Reproducer for the bug (run from another bash shell): -# env -i bash --noprofile --rcfile <(echo 'alias foo="echo EXPANDED"; trap "shopt -u expand_aliases; trap - DEBUG" DEBUG') -ic $'shopt expand_aliases\nfoo\nshopt -u expand_aliases\nfoo' +#-# HARD TO FIX BUG: shopt -u expand_aliases must be run in ENV so bash-abbr works, but ENV is run before the shell switches to interactive +#-# use, and --rcfile is run after. We need to disable expand_aliases AFTER the shell switches to interactive mode, because on that switch +#-# alias expansion is always turned on. You'd think you could use a trap, PROMPT_COMMAND, or bind -x trick for that, but no, there's a bug +#-# currently in bash that prevents exactly that. The only workaround at the moment is to create a custom binding that injects the +#-# shopt -u expand_aliases command ONCE before the very first command. +#-# When bash finally fixes that trap bug, then we don't need to do that anymore. Reproducer for the bug (run from another bash shell): +#-# env -i bash --noprofile --rcfile <(echo 'alias foo="echo EXPANDED"; trap "shopt -u expand_aliases; trap - DEBUG" DEBUG') -ic $'shopt expand_aliases\nfoo\nshopt -u expand_aliases\nfoo' #-# Special aliases that play nicely with my `bash-abbr` bash plugin. The leading `*` means they expand #-# anywhere in the command line (as long as they start a word). Like global aliases in zsh.