-
-
Notifications
You must be signed in to change notification settings - Fork 681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove-echo #612
remove-echo #612
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In many places, echo -e
and echo -ne
are replaced by _omb_util_print
and _omb_util_put
, but these are not interchangeable. The latter two don't process the backslash sequences such as \033
. I initially thought that you've carefully thought about the impact and judged that the behavior can be changed, but after finishing the review, I suspect that you might misunderstand the behavior of _omb_util_print
and _omb_util_put
. Could you check them again?
@@ -15,8 +15,8 @@ source "$HOME/.bashrc" | |||
set | grep -aE "^OSH" | |||
|
|||
if [[ "$OSH_THEME" == "font" ]]; then | |||
echo "Installation succeeded" | |||
printf -- "Installation succeeded" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
printf -- "Installation succeeded" | |
printf '%s\n' "Installation succeeded" |
Newline is missing
else | ||
echo "Installation failed, \$OSH_THEME is not set to 'font'" | ||
printf -- "Installation failed, \$OSH_THEME is not set to 'font'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
printf -- "Installation failed, \$OSH_THEME is not set to 'font'" | |
printf '%s\n' "Installation failed, \$OSH_THEME is not set to 'font'" |
Newline is missing.
@@ -66,9 +66,9 @@ alias ll='ls -lAFh' # Preferred 'ls' implementation | |||
alias less='less -FSRXc' # Preferred 'less' implementation | |||
alias wget='wget -c' # Preferred 'wget' implementation (resume download) | |||
alias c='clear' # c: Clear terminal display | |||
alias path='echo -e ${PATH//:/\\n}' # path: Echo all executable Paths | |||
alias path='printf -- ${PATH//:/\\n}' # path: Echo all executable Paths |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't cover the case where PATH contains %
and other \
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The files under completions/fallback
are taken from the upstream. These should be kept the same as the upstream as much as possible, so we wouldn't change them on our side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is also taken from the upstream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is also taken from the upstream.
@@ -154,7 +154,7 @@ function scm_prompt_info { | |||
|
|||
function scm_prompt_char_info { | |||
scm_prompt_char | |||
echo -ne "${SCM_THEME_CHAR_PREFIX}${SCM_CHAR}${SCM_THEME_CHAR_SUFFIX}" | |||
_omb_util_put "${SCM_THEME_CHAR_PREFIX}${SCM_CHAR}${SCM_THEME_CHAR_SUFFIX}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes the behavior of this function. Users may specify \033...
in SCM_THEME_CHAR_PREFIX
, etc.
However, this behavioral change could be harmless if all the outputs of this function are specified to PS1
as e.g. PS1="$(scm_prompt_char_info)"
. They become PS1='...\033...'
after the command substitution and are finally processed within the PS1
evaluation. If any calls are performed by PS1='$(scm_prompt_char_info)'
, these \033
, etc. will not be expanded and are finally included in the prompt directly. The command substitution will be expanded in the PS1
evaluation phase, but the result will not be further evaluated.
I haven't checked whether there are places affected by this behavioral change. There doesn't seem to be any mention of this behavioral change. There doesn't seem to be an explanation about whether you have paid attention to this possible breakage. Were you aware of this possible problem? Have you confirmed all the calls of this function are not affected by this behavioral change?
@@ -212,7 +212,7 @@ function git_prompt_minimal_info { | |||
# Output the git prompt | |||
SCM_PREFIX=${SCM_THEME_PROMPT_PREFIX} | |||
SCM_SUFFIX=${SCM_THEME_PROMPT_SUFFIX} | |||
echo -e "${SCM_PREFIX}${SCM_BRANCH}${SCM_STATE}${SCM_SUFFIX}" | |||
_omb_util_print "${SCM_PREFIX}${SCM_BRANCH}${SCM_STATE}${SCM_SUFFIX}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the similar changes have the same subtlety. One needs to check the impact on all the calls of these functions.
@@ -146,7 +146,7 @@ OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=true} | |||
DEBUG=0 | |||
function debug { | |||
if [[ ${DEBUG} -ne 0 ]]; then | |||
>&2 echo -e "$@" | |||
>&2 _omb_util_print "$@" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
>&2 _omb_util_print "$@" | |
>&2 _omb_util_print "$@" |
This also changes the behavior.
@@ -74,7 +74,7 @@ function _omb_theme_PROMPT_COMMAND { | |||
fi | |||
|
|||
# Change terminal title | |||
printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}" | |||
_omb_util_put "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_omb_util_put "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}" | |
_omb_util_put "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}" |
This clearly breaks the intended behavior. This directly prints \033]0;...\007
to stdout with the backslash sequences unprocessed.
Thanks for your comments... When you said you would rush to merge your branch containing omb_util_print/omb_util_put, I assumed you did the lifting of making sure they were drop-in replacements for echo/echo -n. That's my bad. No excuses...
I can certainly address the issues you raise...quite expediently...and I will do that. However, not being schooled in the ways of GitHub, I am unsure of the way forward from a logistical point of view. I would
appreciate some advice...
- Did you just reject the PR so that I can withdraw the PR, nuke my fork and start over with a new, sync'ed fork?
- Your comments suggested that you accepted some changes but not others. Do I just sync my fork (and my local repos based on that fork) so that the changes you accepted are merged and move forward with what you suggested?
Inquiring minds want to know...
Thanks in advance.
Message ID: ***@***.***>
… |
They are the drop-in replacements for
You are supposed to update the local branch $ cd <your local clone>
$ <update the codes>
$ git add <modified files>
$ git commit
$ git push origin master Then, this page (i.e. the GitHub interface for the pull request) will automatically reflect the updated branch. If you want to cancel or amend the existing commits, you can perform
No. What I did are the requests for changes, meaning that I'm waiting for you to update the branch. A pull request on GitHub tracks the change of the branch that was used to create the pull request.
No, nothing has been merged. Currently, it is still in the discussion stage. I will accept some of the changes as is, but it's still in my mind. It will not be reflected in the
No need to sync because there are no changes that were actually applied. Please just update your local branch |
What I'm thinking now is to prepare functions that can replace # lib/omb-util.sh
function _omb_util_put_unescape {
local IFS=$' \t\n'
local s="$*"
s=${s/'%'/'%%'}
printf "$s"
}
function _omb_util_print_unescape {
local IFS=$' \t\n'
_omb_util_put_unescape "$*"$'\n'
} One can pass the string to as a format string to Also, some of the cases just passes a fixed string such as |
I was kinda thinking the same thing… I was looking at ‘printf “%q” …”.
Maybe that’s too simplistic…
…On Tue, Sep 10, 2024 at 7:52 PM Koichi Murase ***@***.***> wrote:
What I'm thinking now is to prepare functions that can replace echo -e
and echo -ne. Something like the following:
# lib/omb-util.sh
function _omb_util_put_unescape {
local IFS=$' \t\n'
local s="$*"
s=${s/'%'/'%%'}
printf "$s"
}
function _omb_util_print_unescape {
local IFS=$' \t\n'
_omb_util_put_unescape "$*"$'\n'
}
One can pass the string to as a format string to printf, but one needs to
suppress printf's conversion of %....
Also, some of the cases just passes a fixed string such as '\033c'. These
cases can be converted to $'\033c' so that the called command doesn't
need to handle the conversion of the backslash escape sequences.
—
Reply to this email directly, view it on GitHub
<#612 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BGRNYQDVJX4KST4K4BJ77IDZV6V5NAVCNFSM6AAAAABN7PDHG2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBSGUYDSMBZGA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
|
This pull request replaces a number of occurrences of
echo
withprintf
/_omb_util_print
/_omb_util_put
as appropriate. Note that not all occurrences ofecho
were replaced. Some occurred in comments and some occurrences were not appropriate due to the context of use (e.g., the file was intended to besource
d in a shell other thanbash
).Fixes #606