See here [1] for the code snippet used in one of my forked project:
if [[ ${SHELLOPTS} =~ (vi|emacs) ]]; then
# https://github.com/dvorka/hstr/blob/master/CONFIGURATION.md#bash-binding-hstr-to-keyboard-shortcut
# https://www.computerhope.com/unix/bash/bind.htm
#I'm still not so clear on whether the syntax is case sensitive.
bind -x '"\er": trap '' 2; READLINE_LINE=$(percol_sel_log_history) READLINE_POINT=; trap 2'
#bind -x '"\C-\M-R": trap '' 2; READLINE_LINE=$(percol_sel_log_master_history) READLINE_POINT=; trap 2'
#bind -x '"\C-\M-r": trap '' 2; READLINE_LINE=$(percol_sel_log_master_history) READLINE_POINT=; trap 2'
#bind -x '"\e\C-R": trap '' 2; READLINE_LINE=$(percol_sel_log_master_history) READLINE_POINT=; trap 2'
#bind -x '"\e\C-r": trap '' 2; READLINE_LINE=$(percol_sel_log_master_history) READLINE_POINT=; trap 2'
fi
I've 2 questions on the above code snippet:
1. For the short keys binding to bind command, is the character case-sensitive or not?
2. What does the ``READLINE_POINT='' used above do?
[1] https://github.com/hongyi-zhao/ariadne/blob/b094e0634c4d5890b5ca48fa0a0974adcbe177b0/ariadne.sh#L229
Regards,
HY
See here [1] for the code snippet used in one of my forked project:
if [[ ${SHELLOPTS} =~ (vi|emacs) ]]; then
On 03.09.2021 08:26, hongy...@gmail.com wrote:
See here [1] for the code snippet used in one of my forked project:
if [[ ${SHELLOPTS} =~ (vi|emacs) ]]; thenGiven that SHELLOPTS is a colon-separated list this test appears to
be error prone.
On Saturday, September 4, 2021 at 11:19:08 PM UTC+8, Janis Papanagnou wrote:
On 03.09.2021 08:26, hongy...@gmail.com wrote:
See here [1] for the code snippet used in one of my forked project:Given that SHELLOPTS is a colon-separated list this test appears to
if [[ ${SHELLOPTS} =~ (vi|emacs) ]]; then
be error prone.
What is the special situation that caused its failure?
It really works on my side now:
$ echo ${SHELLOPTS} braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
$ [[ ${SHELLOPTS} =~ (vi|emacs) ]] && echo ok
ok
HY
On 05.09.2021 02:46, hongy...@gmail.com wrote:
On Saturday, September 4, 2021 at 11:19:08 PM UTC+8, Janis Papanagnou wrote: >>> On 03.09.2021 08:26, hongy...@gmail.com wrote:
See here [1] for the code snippet used in one of my forked project:Given that SHELLOPTS is a colon-separated list this test appears to
if [[ ${SHELLOPTS} =~ (vi|emacs) ]]; then
be error prone.
What is the special situation that caused its failure?
If, for example, "vi" is or becomes part of any of the shell option substrings.
$ SHELLOPTS=priviledged
$ [[ ${SHELLOPTS} =~ (vi|emacs) ]] && echo ok
ok
It really works on my side now:
By accident.
The way you do the test is inherently broken.
If you want to test the SHELLOPTS components against two constants you
have to either split SHELLOPTS and compare the parts individually or
add the delimiters (considering not only the colons but also the start
and end of a sting) to the pattern expression.
Janis Papanagnou <janis_pa...@hotmail.com> writes:
On 05.09.2021 02:46, hongy...@gmail.com wrote:
On Saturday, September 4, 2021 at 11:19:08 PM UTC+8, Janis Papanagnou wrote:
On 03.09.2021 08:26, hongy...@gmail.com wrote:
See here [1] for the code snippet used in one of my forked project:Given that SHELLOPTS is a colon-separated list this test appears to
if [[ ${SHELLOPTS} =~ (vi|emacs) ]]; then
be error prone.
What is the special situation that caused its failure?
If, for example, "vi" is or becomes part of any of the shell option substrings.
$ SHELLOPTS=priviledged
$ [[ ${SHELLOPTS} =~ (vi|emacs) ]] && echo ok
ok
It really works on my side now:
By accident.
The way you do the test is inherently broken.
If you want to test the SHELLOPTS components against two constants youThe other way is to add the delimiters to both sides:
have to either split SHELLOPTS and compare the parts individually or
add the delimiters (considering not only the colons but also the start
and end of a sting) to the pattern expression.
[[ ":$SHELLOPTS:" =~ :(vi|emacs): ]]
On 05.09.2021 02:46, hongy...@gmail.com wrote:
On Saturday, September 4, 2021 at 11:19:08 PM UTC+8, Janis Papanagnou wrote:
On 03.09.2021 08:26, hongy...@gmail.com wrote:
See here [1] for the code snippet used in one of my forked project:Given that SHELLOPTS is a colon-separated list this test appears to
if [[ ${SHELLOPTS} =~ (vi|emacs) ]]; then
be error prone.
What is the special situation that caused its failure?If, for example, "vi" is or becomes part of any of the shell option substrings.
$ SHELLOPTS=priviledged
$ [[ ${SHELLOPTS} =~ (vi|emacs) ]] && echo ok
ok
It really works on my side now:By accident.
The way you do the test is inherently broken.
If you want to test the SHELLOPTS components against two constants you
have to either split SHELLOPTS and compare the parts individually or
add the delimiters (considering not only the colons but also the start
and end of a sting) to the pattern expression.
Janis
$ echo ${SHELLOPTS} braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
$ [[ ${SHELLOPTS} =~ (vi|emacs) ]] && echo ok
ok
HY
The way you do the test is inherently broken.
If you want to test the SHELLOPTS components against two constants you
have to either split SHELLOPTS and compare the parts individually or
add the delimiters (considering not only the colons but also the start
and end of a sting) to the pattern expression.
In article <sh15aq$h5k$1...@gioia.aioe.org>,
Janis Papanagnou <janis_pa...@hotmail.com> wrote:
...
The way you do the test is inherently broken.
If you want to test the SHELLOPTS components against two constants youWhich is surprisingly hard to do (correctly). Splitting strings on
have to either split SHELLOPTS and compare the parts individually or
add the delimiters (considering not only the colons but also the start
and end of a sting) to the pattern expression.
delimiters is not something shell script natively does. Yes, it can be kludged, but it is harder than it ought to be. Messing around with IFS
seems to be the way, but doing so is hazardous to your health.
If I were doing this, I'd probably end up doing:
$ gawk -F: '{ for (i=1; i<=NF; i++) if ($i == "vi") exit 1 }' <<< "$SHELLOPTS" ||
echo "Yes, vi is set!"
$
Note: Nothing gawk-specific, but of course, both <<< and SHELLOPS are bash-specific.
--
After 4 years of disastrous screwups, Trump now favors 3 policies that I support:
1) $2K/pp stimulus money. Who doesn't want more money?
2) Water pressure. My shower doesn't work very well; I want Donnie to come fix it.
3) Repeal of Section 230. This will lead to the demise of Face/Twit/Gram. Yey!
In article <sh15aq$h5k$1@gioia.aioe.org>,
Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
...
The way you do the test is inherently broken.
If you want to test the SHELLOPTS components against two constants you
have to either split SHELLOPTS and compare the parts individually or
add the delimiters (considering not only the colons but also the start
and end of a sting) to the pattern expression.
Which is surprisingly hard to do (correctly). Splitting strings on delimiters is not something shell script natively does. Yes, it can be kludged, but it is harder than it ought to be. Messing around with IFS
seems to be the way, but doing so is hazardous to your health.
If I were doing this, I'd probably end up doing:
$ gawk -F: '{ for (i=1; i<=NF; i++) if ($i == "vi") exit 1 }' <<< "$SHELLOPTS" ||
echo "Yes, vi is set!"
$
On 05.09.2021 04:06, Kenny McCormack wrote:
In article <sh15aq$h5k$1@gioia.aioe.org>,
Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
...
The way you do the test is inherently broken.
If you want to test the SHELLOPTS components against two constants you
have to either split SHELLOPTS and compare the parts individually or
add the delimiters (considering not only the colons but also the start
and end of a sting) to the pattern expression.
Which is surprisingly hard to do (correctly). Splitting strings on
delimiters is not something shell script natively does. Yes, it can be
kludged, but it is harder than it ought to be. Messing around with IFS
seems to be the way, but doing so is hazardous to your health.
Actually adding the colon to the pattern that I suggested I consider
quite simple and straightforward, and Ben's hint to also add colons
to the variable on the left to prevent complex patterns on the right
makes it, so I think, a perfect shell code pattern.
In article <sh2a25$tnn$1@gioia.aioe.org>,
Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
On 05.09.2021 04:06, Kenny McCormack wrote:
In article <sh15aq$h5k$1@gioia.aioe.org>,
Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
...
The way you do the test is inherently broken.
If you want to test the SHELLOPTS components against two constants you >>>> have to either split SHELLOPTS and compare the parts individually or
add the delimiters (considering not only the colons but also the start >>>> and end of a sting) to the pattern expression.
Which is surprisingly hard to do (correctly). Splitting strings on
delimiters is not something shell script natively does. Yes, it can be
kludged, but it is harder than it ought to be. Messing around with IFS
seems to be the way, but doing so is hazardous to your health.
Actually adding the colon to the pattern that I suggested I consider
quite simple and straightforward, and Ben's hint to also add colons
to the variable on the left to prevent complex patterns on the right
makes it, so I think, a perfect shell code pattern.
You are totally missing the point.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 34:43:36 |
Calls: | 6,648 |
Calls today: | 3 |
Files: | 12,193 |
Messages: | 5,328,827 |