View previous topic :: View next topic |
Author |
Message |
josephg l33t
Joined: 10 Jan 2016 Posts: 783 Location: usually offline
|
Posted: Thu Jan 11, 2018 9:46 pm Post subject: .bashrc issue [resolved] |
|
|
i created this thread, as i didn't want to hijack another thread when i hit this issue.
bash gives me no output the command below, whereas it works fine in dash and i get the expected output.
Code: | $ gcc -march=native -### -E - $2 2>&1 | sed -r '/cc1/!d;s/(\")|(^.* - )//g' |
troubleshooting this, i ended up in ~/.bashrc and then very specifically at a particular line. if i remove this line below, i get the expected output. if i keep this line, bash gives me no output from the above command.
Code: | set show-all-if-ambiguous on |
the man page says
$ man bash: |
show-all-if-ambiguous (Off)
This alters the default behavior of the completion functions. If set to On, words which have more than one possible completion cause the matches to be listed immediately instead of ringing
the bell.
show-all-if-unmodified (Off) |
could you shed some light on this? i have had this line in my ~/.bashrc for a long time, and now i've forgottern why. i wonder if the recent bash rebuld due to readline changed something. _________________ "Growth for the sake of growth is the ideology of the cancer cell." Edward Abbey
Last edited by josephg on Sat Jan 13, 2018 11:36 pm; edited 3 times in total |
|
Back to top |
|
|
khayyam Watchman
Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Thu Jan 11, 2018 10:26 pm Post subject: Re: bash issue? |
|
|
josephg wrote: | Code: | $ gcc -march=native -### -E - $2 2>&1 | sed -r '/cc1/!d;s/(\")|(^.* - )//g' |
|
josephg ... a number of things which might go wrong:
1). '#' is a special char, in the above you should be single quoting: '-###'.
2). What is "$2"?
Code: | % /bin/echo a b c $2 d e f g
a b c d e f g |
You probably want:
Code: | # gcc -march=native '-###' -E - 2>&1 | sed -r '/cc1/!d;s/(\")|(^.* - )//g' |
HTH & best ... khay |
|
Back to top |
|
|
krinn Watchman
Joined: 02 May 2003 Posts: 7470
|
Posted: Thu Jan 11, 2018 10:37 pm Post subject: Re: bash issue? |
|
|
khayyam wrote: | 2). What is "$2"? |
my fault, in my script just the given second parameter to the function, forget to remove it |
|
Back to top |
|
|
josephg l33t
Joined: 10 Jan 2016 Posts: 783 Location: usually offline
|
Posted: Thu Jan 11, 2018 10:41 pm Post subject: |
|
|
ah thank you khay. all of them i guess. i must remind myself to understand things. i took that command line from this post.
your modified command works now.
Code: | $ gcc -march=native -### -E - $2 2>&1 | sed -r '/cc1/!d;s/(\")|(^.* - )//g'
$ gcc -march=native '-###' -E - $2 2>&1 | sed -r '/cc1/!d;s/(\")|(^.* - )//g'
$ gcc -march=native '-###' -E - 2>&1 | sed -r '/cc1/!d;s/(\")|(^.* - )//g'
-march=core2 -mmmx -mno-3dnow -msse -msse2 -msse3 -mssse3 -mno-sse4a -mcx16 -msahf -mno-movbe -mno-aes -mno-sha -mno-pclmul -mno-popcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-bmi2 -mno-tbm -mno-avx -mno-avx2 -mno-sse4.2 -mno-sse4.1 -mno-lzcnt -mno-rtm -mno-hle -mno-rdrnd -mno-f16c -mno-fsgsbase -mno-rdseed -mno-prfchw -mno-adx -mfxsr -mno-xsave -mno-xsaveopt -mno-avx512f -mno-avx512er -mno-avx512cd -mno-avx512pf -mno-prefetchwt1 -mno-clflushopt -mno-xsavec -mno-xsaves -mno-avx512dq -mno-avx512bw -mno-avx512vl -mno-avx512ifma -mno-avx512vbmi -mno-clwb -mno-mwaitx -mno-clzero -mno-pku --param l1-cache-size=32--param l1-cache-line-size=64 --param l2-cache-size=2048 -mtune=core2 |
but now i wonder with those reasons you mentioned, why should this command work at all? it works in dash, and it seems to work for others. bash and dash should process # as comment and $2 is null as you pointed out.
Code: | $ gcc -march=native -### -E - $2 2>&1 | sed -r '/cc1/!d;s/(\")|(^.* - )//g' |
|
|
Back to top |
|
|
khayyam Watchman
Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Thu Jan 11, 2018 11:04 pm Post subject: |
|
|
josephg wrote: | but now i wonder with those reasons you mentioned, why should this command work at all? it works in dash, and it seems to work for others. bash and dash should process # as comment and $2 is null as you pointed out. |
josephg ... I think because of something set in your .bashrc ... I can't reproduce.
best ... khay |
|
Back to top |
|
|
josephg l33t
Joined: 10 Jan 2016 Posts: 783 Location: usually offline
|
Posted: Fri Jan 12, 2018 12:01 am Post subject: |
|
|
i can reproduce it
Code: | $ cat .bashrc
set show-all-if-ambiguous on
$ gcc -march=native -### -E - $2 2>&1 | sed -r '/cc1/!d;s/(\")|(^.* - )//g'
$ |
Code: | $ cat ~/.bashrc
#set show-all-if-ambiguous on
$ gcc -march=native -### -E - $2 2>&1 | sed -r '/cc1/!d;s/(\")|(^.* - )//g'
-march=core2 -mmmx -mno-3dnow -msse -msse2 -msse3 -mssse3 -mno-sse4a -mcx16 -msahf -mno-movbe -mno-aes -mno-sha -mno-pclmul -mno-popcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-bmi2 -mno-tbm -mno-avx -mno-avx2 -mno-sse4.2 -mno-sse4.1 -mno-lzcnt -mno-rtm -mno-hle -mno-rdrnd -mno-f16c -mno-fsgsbase -mno-rdseed -mno-prfchw -mno-adx -mfxsr -mno-xsave -mno-xsaveopt -mno-avx512f -mno-avx512er -mno-avx512cd -mno-avx512pf -mno-prefetchwt1 -mno-clflushopt -mno-xsavec -mno-xsaves -mno-avx512dq -mno-avx512bw -mno-avx512vl -mno-avx512ifma -mno-avx512vbmi -mno-clwb -mno-mwaitx -mno-clzero -mno-pku --param l1-cache-size=32--param l1-cache-line-size=64 --param l2-cache-size=2048 -mtune=core2 |
|
|
Back to top |
|
|
khayyam Watchman
Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Fri Jan 12, 2018 1:54 am Post subject: |
|
|
josephg wrote: | Code: | set show-all-if-ambiguous on |
|
josephg ... the behavior doesn't seem related to being "on".
Code: | % /bin/bash --login
$ set show-all-if-ambiguous off
$ gcc -march=native -### -E - $2 2>&1 | sed -r '/cc1/!d;s/(\")|(^.* - )//g'
$ |
So, as the default is "off", this should have no effect whatsoever. The problem is elsewhere, I suspect readline, because that is a readline variable. I'm not a bash user, so it's possible there is some other factor I'm not aware of.
best ... khay |
|
Back to top |
|
|
josephg l33t
Joined: 10 Jan 2016 Posts: 783 Location: usually offline
|
Posted: Sat Jan 13, 2018 10:18 pm Post subject: |
|
|
khayyam wrote: | the behavior doesn't seem related to being "on". |
i agree. that's why i raised this issue.
khayyam wrote: | Code: | % /bin/bash --login
$ set show-all-if-ambiguous off
$ gcc -march=native -### -E - $2 2>&1 | sed -r '/cc1/!d;s/(\")|(^.* - )//g'
$ |
So, as the default is "off", this should have no effect whatsoever. The problem is elsewhere, I suspect readline, because that is a readline variable. I'm not a bash user, so it's possible there is some other factor I'm not aware of. |
thanks for trying. are you able to replicate it too?
i can not replicate it from cmdline, but i can with just that one line in ~/.bashrc
i have no idea what to look for or change in readline. |
|
Back to top |
|
|
khayyam Watchman
Joined: 07 Jun 2012 Posts: 6227 Location: Room 101
|
Posted: Sat Jan 13, 2018 10:57 pm Post subject: |
|
|
josephg wrote: | thanks for trying. are you able to replicate it too?i can not replicate it from cmdline, but i can with just that one line in ~/.bashrc |
josephg ... the above is exactly what I'd typed on the command line, further:
Code: | % /bin/bash --login
$ set show-all-if-ambiguous off
$ echo $2
off
$ gcc -march=native -### -E - $2 2>&1 | sed -r '/cc1/!d;s/(\")|(^.* - )//g'
$ set 'show-all-if-ambiguous off'
$ echo $1
show-all-if-ambiguous off |
So, there's the explanation.
HTH & best ... khay |
|
Back to top |
|
|
josephg l33t
Joined: 10 Jan 2016 Posts: 783 Location: usually offline
|
Posted: Sat Jan 13, 2018 11:33 pm Post subject: |
|
|
khayyam wrote: | So, there's the explanation. |
you're da man! every problem has a simple explanation..
thank you
Code: | $ cat .bashrc
set show-all-if-ambiguous on
$ gcc -march=native -### -E - $2 2>&1 | sed -r '/cc1/!d;s/(\")|(^.* - )//g'
$ echo $1
show-all-if-ambiguous
$ echo $2
on
$ set -x
$ gcc -march=native -### -E - $2 2>&1 | sed -r '/cc1/!d;s/(\")|(^.* - )//g'
+ sed -r '/cc1/!d;s/(\")|(^.* - )//g'
+ gcc -march=native -### -E - on
$ |
Code: | $ cat .bashrc
#set show-all-if-ambiguous on
$ echo $2
$ gcc -march=native -### -E - $2 2>&1 | sed -r '/cc1/!d;s/(\")|(^.* - )//g'
-march=core2 -mmmx -mno-3dnow -msse -msse2 -msse3 -mssse3 -mno-sse4a -mcx16 -msahf -mno-movbe -mno-aes -mno-sha -mno-pclmul -mno-popcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-bmi2 -mno-tbm -mno-avx -mno-avx2 -mno-sse4.2 -mno-sse4.1 -mno-lzcnt -mno-rtm -mno-hle -mno-rdrnd -mno-f16c -mno-fsgsbase -mno-rdseed -mno-prfchw -mno-adx -mfxsr -mno-xsave -mno-xsaveopt -mno-avx512f -mno-avx512er -mno-avx512cd -mno-avx512pf -mno-prefetchwt1 -mno-clflushopt -mno-xsavec -mno-xsaves -mno-avx512dq -mno-avx512bw -mno-avx512vl -mno-avx512ifma -mno-avx512vbmi -mno-clwb -mno-mwaitx -mno-clzero -mno-pku --param l1-cache-size=32--param l1-cache-line-size=64 --param l2-cache-size=2048 -mtune=core2 |
i think it strange behaviour that $2 remains even after many commands in from the start of the shell. i think that option is not safe, and will keep it off as default. thank you! |
|
Back to top |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21607
|
Posted: Sat Jan 13, 2018 11:36 pm Post subject: |
|
|
The sed statement is designed to discard everything except the one interesting line. The redirect of stderr to stdout causes sed to filter stderr. Inclusion of a non-existent filename causes gcc to print an error message to stderr instead of printing the data you want. This is not a bash bug or quirk. The bash command set changes the argument list, so set show-all-if-ambiguous off causes $1=show-all-if-ambiguous and $2=off. If you do not have a preprocessable file named off in the current working directory, then gcc will print gcc: error: off: No such file or directory, which the sed will then delete. As a silly workaround, create an empty file named off before you run this command.
You are trying to use bashrc to change readline directives. This is the wrong place. Use inputrc. |
|
Back to top |
|
|
josephg l33t
Joined: 10 Jan 2016 Posts: 783 Location: usually offline
|
Posted: Sat Jan 13, 2018 11:42 pm Post subject: |
|
|
thank you Hu. khay was right all along to suspect readline issue. and i didn't understand what that meant. thank you also for pointing me towards inputrc. so now i can use that option again and safely so. thanks again to both of you for helping me understand. |
|
Back to top |
|
|
josephg l33t
Joined: 10 Jan 2016 Posts: 783 Location: usually offline
|
Posted: Sun Jan 14, 2018 11:17 am Post subject: |
|
|
Hu wrote: | You are trying to use bashrc to change readline directives. This is the wrong place. Use inputrc. |
i also had another readline set directive in .bashrc, which i moved to .inputrc and now i get this
Code: | readline: -o: unknown variable name |
|
|
Back to top |
|
|
cboldt Veteran
Joined: 24 Aug 2005 Posts: 1046
|
Posted: Sun Jan 14, 2018 11:42 am Post subject: |
|
|
Check `man readline` for what can be set in .inputrc. The syntax in .inputrc is "set VARIABLE", not "set -o VARIABLE"
Looking at `man readline`, I see no variable named "vi" although there is a "vi-editing-mode" and numerous edit functions that use "vi-" naming convention.
The group of bash attributes manipulated by `set -o` has an attribute "vi" that is similar (but not the same) as readline's "vi-editing-mode"
It is possible to cause the command line to enter vi mode from the bash command line. Just enter "set -o vi" and the deed is done. Putting that in .bashrc causes that to be done automatically on shell startup.
So, if in bashrc
On my system, the readline function designations described in `man bash` are not exactly the same as in `man readline`, but in any event, I have the impression that the readline/.inputrc setting is used to bind a command line key combination to entering vi-editing-mode. That is, an entry in .inputrc doesn't automatically put the command line in vi-mode. |
|
Back to top |
|
|
josephg l33t
Joined: 10 Jan 2016 Posts: 783 Location: usually offline
|
Posted: Sun Jan 14, 2018 5:04 pm Post subject: |
|
|
i think i'm still a bit confused about which "set" goes to .bashrc vs .inputrc
man bash: | READLINE
This is the library that handles reading input when using an interactive shell, unless the --noediting option is given at shell invocation. Line editing is also used when using the -e option to the
read builtin. By default, the line editing commands are similar to those of Emacs. A vi-style line editing interface is also available. Line editing can be enabled at any time using the -o emacs
or -o vi options to the set builtin (see SHELL BUILTIN COMMANDS below). To turn off line editing after the shell is running, use the +o emacs or +o vi options to the set builtin. |
"man readline" doesn't tell me much http://termbin.com/5ong |
|
Back to top |
|
|
cboldt Veteran
Joined: 24 Aug 2005 Posts: 1046
|
Posted: Sun Jan 14, 2018 6:21 pm Post subject: |
|
|
These work from the bash command line, or as set in .bashrc. Pick one or the other.
Code: | set -o vi
set -o emacs |
These work in .inputrc, and do exactly the same thing as the above-referenced bash command line or .bashrc commands. Pick one or the other.
Code: | set editing-mode vi
set editing-mode emacs |
The default is use of emacs editing mode.
In addition, according to the readline man file, default key bindings as follows are used to switch between editing modes
When in "vi editing mode", Ctl-e switches to emacs editing mode.
When in "emacs editing mode," Ctl-Alt-j switches to vi editing mode. |
|
Back to top |
|
|
josephg l33t
Joined: 10 Jan 2016 Posts: 783 Location: usually offline
|
Posted: Sun Jan 14, 2018 7:52 pm Post subject: |
|
|
cboldt wrote: | When in "vi editing mode", Ctl-e switches to emacs editing mode.
When in "emacs editing mode," Ctl-Alt-j switches to vi editing mode. |
thank you again. this is very useful to know too.
my readline manual page seems to be a bit brief http://termbin.com/5ong |
|
Back to top |
|
|
cboldt Veteran
Joined: 24 Aug 2005 Posts: 1046
|
Posted: Sun Jan 14, 2018 8:13 pm Post subject: |
|
|
That man page is for "uxrvt-readline," not "readline"
What do you see with `apropos readline`
Code: | > apropos readline
readline (3) - get a line from a user with editing
regshell (1) - Windows registry file browser using readline |
If no manpage (for readline) there, you might find some useful information at `ls /usr/share/doc/readline-*` or by invoking `info readline` |
|
Back to top |
|
|
josephg l33t
Joined: 10 Jan 2016 Posts: 783 Location: usually offline
|
Posted: Sun Jan 14, 2018 8:41 pm Post subject: |
|
|
Code: | $ apropos readline
pipeline_readline (3) - pipeline manipulation library
urxvt-readline (1) - improve readline editing (enabled by default)
readline (3) - get a line from a user with editing |
wonder why my formatting looks a bit off than yours.. ie spaces alignment |
|
Back to top |
|
|
cboldt Veteran
Joined: 24 Aug 2005 Posts: 1046
|
Posted: Sun Jan 14, 2018 9:24 pm Post subject: |
|
|
try `man 3 readline`
Not sure why the formatting is different. I use a monospaced font. There may be other settings that affect either the output of "apropos" or the display of whitespace. |
|
Back to top |
|
|
|