Re: Handling files with CRLF line ending

2022-12-08 Thread Chris Elvidge
On 08/12/2022 19:34, Ángel wrote: On 2022-12-07 at 12:38 +, Chris Elvidge wrote: I don't use Python generally, but my understanding of it (only a quick test) f = open("demofile2.txt", "a") f.write("Now the file has more content!") f.close() f.write doesn't a

Re: Handling files with CRLF line ending

2022-12-07 Thread Chris Elvidge
On 06/12/2022 23:39, L A Walsh wrote: On 2022/12/06 10:57, Chris Elvidge wrote: Yair, how about using the Python installed in the WSL instance. --- Oh, I wondered why Python used CRLF, but nothing else did. What version of python are you using? The Python for WSL, the python

Re: Handling files with CRLF line ending

2022-12-06 Thread Chris Elvidge
there. Windows text files have to be converted to Linux format before processing - either inline (tr -d '\r') or in mass (dos2unix). Expecting bash to cope is a non-starter. Yair, how about using the Python installed in the WSL instance. -- Chris Elvidge England

Re: forwarded weirdness report

2022-03-29 Thread Chris Elvidge
On 28/03/2022 22:00, Greg Wooledge wrote: Or -- and I know this answer will be rejected, because it's too simple and sensible -- stop using aliases in scripts. +1 Or could just stop answering questions about aliases in scripts -- Chris Elvidge England

Re: Squiggly heredoc - new feature request

2021-08-30 Thread Chris Elvidge
blabla EOF ) This would break backward compatibility and POSIX compliance. I'm sure there are real life scripts that have leading spaces in their here-doc payloads which should be preserved. Yes there are. -- Chris Elvidge England

Re: `&>' doesn't behave as expected in POSIX mode

2021-06-20 Thread Chris Elvidge
err and stdout to `/dev/null'. Oğuz If you want to parse them as two separate commands, separate them. -- Chris Elvidge England

Re: Default PS1

2021-03-29 Thread Chris Elvidge
On 29/03/2021 12:04 pm, ილია ჩაჩანიძე wrote: How can I set default PS1 variable from source code? E.g I want it to display: My-linux-distro $ And not: Bash-5.1 $ Set it in $HOME/.bashrc -- Chris Elvidge England

Re: is it a bug that PWD=whatever sets PS1's \w to that regardless

2021-03-16 Thread Chris Elvidge
$PWD If you want to register the current directory in $PS1 regardless, change \w to `pwd` -- Chris Elvidge England

Re: syntax error while parsing a case command within `$(...)'

2021-02-16 Thread Chris Elvidge
the necessity of an additional explanation... Thank you for the comment! -- Koichi -- Chris Elvidge England

Re: bash doesn't display user-typed characters; can interfere with COPY/PASTE

2020-12-08 Thread Chris Elvidge
that used on old-hardware terminals. Thanks, -l Try Ctrl-V before hitting . -- Chris Elvidge England

Re: [ping] declare -c still undocumented.

2020-11-13 Thread Chris Elvidge
z But ${var^} still doesn't know that it should apply to the first alpha character in a string. Similar for , and ~. If the first character of the string is a punctuation character, e.g.(, it doesn't work (as I would like it to ). -- Chris Elvidge England

Re: Bad substitution breaks conditional statement

2020-10-12 Thread Chris Elvidge
to check if version X-1 is being used and throw an error there. Isn't that what $BASH_VERSION / $BASH_VERSINFO is for? -- Chris Elvidge England

Re: Incrementing variable=0 with arithmetic expansion causes Return code = 1

2020-08-28 Thread Chris Elvidge
.ch/> From man bash: ((expression)) The expression is evaluated according to the rules described below under ARITHMETIC EVALUATION. If the value of the expression is non-zero, the return status is 0; otherwise the return status is 1. This is exactly equivalent to let "expression".

Re: Expand first before asking the question "Display all xxx possibilities?"

2020-08-05 Thread Chris Elvidge
o you choose for the first expansion? Thanks for the suggestion. -- Chris Elvidge England

Re: Return from function depending on number of parameters

2020-07-10 Thread Chris Elvidge
rithmetic context) of [...] connected/related? Or am I (stupidly) seeing a connection where none really exists? Thanks -- Chris Elvidge England

Re: Return from function depending on number of parameters

2020-07-09 Thread Chris Elvidge
On 06/07/2020 12:50 pm, Greg Wooledge wrote: On Fri, Jul 03, 2020 at 07:00:54PM +0100, Chris Elvidge wrote: I've used 'return $((!$#))' and 'return $[!$#]' to return an error if no parameters given to function. The problem with this is that it *always* returns from the function, even when

Re: Return from function depending on number of parameters

2020-07-04 Thread Chris Elvidge
On 03/07/2020 11:16 pm, Eli Schwartz wrote: On 7/3/20 2:00 PM, Chris Elvidge wrote: I've used 'return $((!$#))' and 'return $[!$#]' to return an error if no parameters given to function. Tested in a bash script 'exit $((!$#)) / $[!$#]' - both work. 'echo $((!$#)) / $[!$#]' - both echo 1 when

Re: Return from function depending on number of parameters

2020-07-04 Thread Chris Elvidge
On 03/07/2020 10:39 pm, Lawrence Velázquez wrote: On Jul 3, 2020, at 2:00 PM, Chris Elvidge wrote: However 'N=0; echo $((!$N))' gives an error at the bash prompt. 'echo $[!$N]' echo's 1 as expected. My question - is $[...] actually obsolete? It might tell you something

Re: Return from function depending on number of parameters

2020-07-04 Thread Chris Elvidge
On 03/07/2020 11:16 pm, Eli Schwartz wrote: On 7/3/20 2:00 PM, Chris Elvidge wrote: I've used 'return $((!$#))' and 'return $[!$#]' to return an error if no parameters given to function. Tested in a bash script 'exit $((!$#)) / $[!$#]' - both work. 'echo $((!$#)) / $[!$#]' - both echo 1 when

Re: Return from function depending on number of parameters

2020-07-04 Thread Chris Elvidge
On 03/07/2020 10:39 pm, Lawrence Velázquez wrote: On Jul 3, 2020, at 2:00 PM, Chris Elvidge wrote: However 'N=0; echo $((!$N))' gives an error at the bash prompt. 'echo $[!$N]' echo's 1 as expected. My question - is $[...] actually obsolete? It might tell you something

Return from function depending on number of parameters

2020-07-03 Thread Chris Elvidge
the same effect? Cheers -- Chris Elvidge