[gitstatus] `stty: invalid argument` on `source`, patch 0.3.3

ble version: 0.3.3+7fa584c

Bash version: 5.0.17(1)-release, x86_64-redhat-linux-gnu

I downloaded Patch 0.3.3 and want to try it out:

$ source 
/usr/bin/stty: invalid argument ‘_ble_term_stty_flags_enter+=("${@:2}")’
Try '/usr/bin/stty --help' for more information.

When I source it a second time:

$ source 
[ble: reload]
stty: invalid argument ‘_ble_term_stty_flags_leave+=("${@:2}")’
Try 'stty --help' for more information.
stty: invalid argument ‘_ble_term_stty_flags_leave+=("${@:2}")’
Try 'stty --help' for more information.
bash: eval: line 254: syntax error near unexpected token `('
bash: eval: line 254: `exec _ble_util_openat_fdlist+=("${@:2}")>&-'
bash: eval: line 254: syntax error near unexpected token `('
bash: eval: line 254: `exec _ble_util_openat_fdlist+=("${@:2}")>&-'
bash: eval: line 254: syntax error near unexpected token `('
bash: eval: line 254: `exec _ble_util_openat_fdlist+=("${@:2}")>&-'
^[[39;2Rbash: 10#fields: value too great for base (error token is "10#fields")
/usr/bin/stty: invalid argument ‘_ble_term_stty_flags_enter[${#_ble_term_stty_flags_enter[@]}]="$2"’
Try '/usr/bin/stty --help' for more information.
\033[01;32m\u@\h\033[00m \033[01;34m\w\033[00m\n\033[01;31m$\033[00m \e]0;\u@\h: \w\abash: /home/ofey/.cache/blesh/./cmap+default.3.xterm-256color.dump: line 9: syntax error near unexpected token `('
bash: /home/ofey/.cache/blesh/./cmap+default.3.xterm-256color.dump: line 9: `_ble_decode_csimap_tilde=([1]=key=(\${*:2}))'
            ble-bind: Unknown ble edit function `arr=(${*:2})'.
ble-bind: Unknown ble edit function `arr=(${*:2})'.

# ... About 150 lines replicate error.

ble-bind: Unknown ble edit function `arr=(${*:2})'.
bash: seq=(${*:2}): syntax error: operand expected (error token is "${*:2})")

Besides, my stty version is: 8.32

$ stty --version
stty (GNU coreutils) 8.32
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David MacKenzie.

After all, thank you all for creating this good thing.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (7 by maintainers)

Most upvoted comments

Sorry for the late reply. I’m now busy, so it will take some time to think about what is the proper way of the workaround and to implement it.

yeah, I forgot to add the a \ to eval. (comment by @SuperSandro2000)

OK, I see. It’s exec but not eval, but this seems to be the same problem caused by

OOP: I’m surprised you are a postdoc in physics in Peking University! I’m a undergraduate in Fudan University majored physics too. Nice to meet you. Video of cxxmatrix really surprised me, it’s awesome! (comment by @ofey404)

Nice to meet you! And, thank you for trying out cxxmatrix!

Besides, if I want to know more about bash, where should I start? I’m reading Advanced Bash Scripting Guide now. (comment by @ofey404)

I think maybe I cannot make a satisfactory answer for you since I mainly learned Bash by reading man bash and searching related materials by taking a long time. When I started to use Bash, I have read some sections of man bash that seem to be useful, and gradually expanded to the other sections. When I found in man bash some Bash features that I couldn’t get how to use, I searched it by Google, read related pages, and tried it by writing actual scripts. This is the way I learned Bash.

  • The most reliable source is of course the official documents. You can check man bash for a good summary. A more detailed description of Bash can be found in Bash Reference Manual through HTML or the command info bash.
  • I think BashGuide - Greg’s Wiki and BashFAQ - Greg’s Wiki are the most comprehensive guides and FAQ (from basic to advanced, etc.) on Bash scripting. This Wiki is well maintained by Greg Wooledge, one of regular participants of the official Bash mailing lists bug-bash and help-bash (see the next item).
  • After you have roughly understood all the sections of man bash, it would be also useful to subscribe bug-bash mailing list and help-bash mailing list to learn detailed Bash behaviors and techniques which are not fully documented in Bash man pages and manuals, but about which people often have questions. (Though just recently some guy is posting many unthoughtful questions and complaints.)

There are also some popular documents, but I don’t fully recommend them. They will provide you some interesting techniques, but some techniques are not robust, so be careful:

  • Bash Hackers Wiki is sometimes referenced by people. Most part of this Wiki is fine, yet it contains many suspicious descriptions partly because, I think, this Wiki is edited by anonymous not-well-trained Bash programmers.
  • dylanaraps/pure-bash-bible is another popular document that contains useful techniques but also contains incomplete and inefficient techniques.

Well, then my bash prompt takes 2 seconds to load which is unusable. (comment by @SuperSandro2000)

I think you can put GITSTATUS_STOP_ON_EXEC=0 before the source of (instead of completely disabling gitstatusd).

I guess is doing some initialization(Sorry I don’t save the outputs). (comment by @ofey404)

Right. You can see the initialization process again after rm -rf "$_ble_base_cache"/*.

@ofey404 @SuperSandro2000 I’ve reported the issue of at, and a fix has been made in the master of gitstatus. I think the root cause of alias builtin and alias exec will be solved in the next release of gitstatus. Now let me close this issue.

Thank you very much for reporting the issue and having provided us with a related issue with gitstatus and docker!

Thank you for the information!

Besides, maybe we should close this issue?

Could we keep it open for a while? I think we should report it to gitstatus, but currently I’m busy. I actually would like to suggest gitstatus changing to turn off the replacement of builtins by default. In order to support the change, I would like to collect the patterns that can be broken by replacing exec and builtin, but it may take time.

  • builtin eval would see wrong positional parameters $1, $2, ..., $@ if buitlin is replaced by a function. builtin source file (without arguments) also have the same problem.
  • The file descriptors set up by exec 3> file is not persistent after the exec if exec is replaced by a function.
  • Also, as @SuperSandro2000 has reported, sudo docker exec would be affected by the alias.
  • etc.

But I haven’t yet really tested them.

P.S. ⭐ bash-git-prompt seems fully compatible with

Besides, maybe we should close this issue?

Thank you. I actually cannot reproduce the behavior, but with builtin() { "$@"; } I could reproduce a similar behavior. If builtin or eval is not replaced, currently I don’t have an idea what happens in your environment. To narrow down the problem, I have additional questions:

  • Q1. Is the problem reproduced with the plain Bash without any configuration? You can test it with the following commands:
$ INPUTRC=/dev/null bash --norc --noprofile
$ source
  • Q2. Is the problem reproduced with the devel version of (i.e., master branch)?