Re: bash "extglob" needs to upgrade at least like zsh "kshglob"

2022-10-31 Thread Greg Wooledge
On Mon, Oct 31, 2022 at 05:00:40AM +0200, Oğuz wrote:
> 31 Ekim 2022 Pazartesi tarihinde Martin D Kealey 
> yazdı:
> > If we use the standard POSIX BRE or ERE, then there's no additional code to
> > ship; it's included as part of the OS. The hard part is what to do with
> > (!LIST), which was the point of my previous post.
> 
> That'd be clunkier than what we already have. Bash targets many platforms
> and it'd have to target as many regex engines if it were to translate
> extglobs to posix regexes. You can't expect all of them to be compatible
> with each other, and they are not. So, if we wish to translate extglobs to
> regexes and have them work regardless of the platform, the easiest way
> forward is to adopt a third party regex engine; about which I said enough
> in my previous email.

Bash already uses the POSIX regex functions (regcomp(3) et al.) to do
[[ =~ ]] using POSIX ERE.  If it weren't for !(list) it would be possible,
even easy, for bash to convert extglobs into POSIX EREs, syntactically,
and then call the same libraries it's already calling.

I'm not sure where your claim of incompatibility comes from.

Regardling !(list), I know that many people use it.  It's fairly
popular, at least among the sort of people who come to IRC asking how
they can match all files except foo and bar.  So, simply dropping it
would not be a viable option.



Re: Subsequent Here Doc/String Never Evaluated in Process Substitution

2022-10-31 Thread Chet Ramey

On 10/28/22 6:37 AM, ad...@nosuck.org wrote:
Thank you for the awesome shell.  I noticed the following after upgrading 
from 5.1.16-3 to 5.2.2-2 on Fedora.  It actually resulted in a minor amount 
of data loss.


Thanks for the report. I believe this was fixed a couple of weeks ago as
the result of

https://lists.gnu.org/archive/html/bug-bash/2022-10/msg00092.html

The fix is in the devel branch.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/




Re: bash "extglob" needs to upgrade at least like zsh "kshglob"

2022-10-31 Thread Oğuz İsmail Uysal

On 10/31/22 2:20 PM, Greg Wooledge wrote:

Bash already uses the POSIX regex functions (regcomp(3) et al.) to do
[[ =~ ]] using POSIX ERE. 
Yeah, and offers no more than what your libc's regex engine has. For 
example, you can't tell what `[[ x =~ .{256} ]]' (or even `[[ x =~ "" 
]]') would return without knowing the operating system it's run on. 
extglobs aren't like that and shouldn't be either.




Re: local/typeset/declare -p - outputs invalid declare -- -

2022-10-31 Thread Greg Wooledge
On Mon, Oct 31, 2022 at 06:12:14PM +0100, Alex fxmbsw7 Ratchev wrote:
> hi , sorry.. whats the purpose of local -
> informational question

a. Since there is no `declare -' equivalent of `local -', make sure to use
   `local -' in the output of `local -p'.

-

s.  The `local' builtin takes a new argument: `-', which will cause it to save
the single-letter shell options and restore their previous values at
function return.

>From two different parts of CHANGES.



Re: Multiline editing breaks if the previous output doesn't end in newline

2022-10-31 Thread Chet Ramey

On 10/30/22 9:40 PM, Oğuz wrote:


Yeah, or add a new prompt sequence (e.g. \N) that prints a newline only if
the cursor is not at column 0.


There is no portable way to determine this.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/




Re: bash "extglob" needs to upgrade at least like zsh "kshglob"

2022-10-31 Thread Chet Ramey

On 10/30/22 9:59 PM, Martin D Kealey wrote:


With the exception of the !(LIST) negation, there's a direct correspondence
between extglob and any other regex format. Translating between them is
trivial.


As I said before, I would gladly look at incorporating such a change, as
long as it didn't increase the number of dependencies.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/




Re: local/typeset/declare -p - outputs invalid declare -- -

2022-10-31 Thread Alex fxmbsw7 Ratchev
On Mon, Oct 31, 2022, 18:31 Greg Wooledge  wrote:

> On Mon, Oct 31, 2022 at 06:12:14PM +0100, Alex fxmbsw7 Ratchev wrote:
> > hi , sorry.. whats the purpose of local -
> > informational question
>
> a. Since there is no `declare -' equivalent of `local -', make sure to use
>`local -' in the output of `local -p'.
>
> -
>
> s.  The `local' builtin takes a new argument: `-', which will cause it to
> save
> the single-letter shell options and restore their previous values at
> function return.
>
> From two different parts of CHANGES.
>

cool mate , perfect answer
im sorry that i cant digg thru so much text
but hey chat worked , =)
hm it only saves the like -mBH or similiar ?
hm
dont get it much

>
>


Re: Function declarations produce no trace nor trigger debug trap while having side effects

2022-10-31 Thread Chet Ramey

On 10/28/22 12:09 PM, Erik Adelbert wrote:

Hello Chet and other bash maintainers,

Thanks for your time.

On 27 Oct 2022, at 23:26, Chet Ramey > wrote:


we believe the current semantic to be at least unclear and would like to 
see either:

0 the DEBUG trap called _before_ any function declaration (preferred)


While calling the DEBUG trap before certain compound commands has value, I
don't think that function definition commands rise to that level.


In the demonstrated case (2nd example of our report), we made clear that
commenting in/out a function definition *seemed* to make an unrelated
error appear/disappear from the debugging support because it was in the
vicinity.


There are a couple of ways to overcome that. You could save and restore the
value of $? around a function declaration, or you could reorder code so
that function definitions come before the command whose exit status you're
interested in.


--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/




Re: bash "extglob" needs to upgrade at least like zsh "kshglob"

2022-10-31 Thread Chet Ramey

On 10/28/22 2:44 AM, Hyunho Cho wrote:


Bash Version: 5.2
Patch Level: 2
Release Status: release

##

bash "extglob" almost unusable except with very tiny string.
there is no such problems in zsh "kshglob".


Nothing has changed since you brought this up last month. The same two-line
sed workaround works on the 90K string from `gcc --help'.

https://lists.gnu.org/archive/html/bug-bash/2022-09/msg00029.html

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/




Re: local/typeset/declare -p - outputs invalid declare -- -

2022-10-31 Thread Alex fxmbsw7 Ratchev
hi , sorry.. whats the purpose of local -
informational question

On Mon, Oct 31, 2022, 17:45 Emanuele Torre  wrote:

> Since bash 5.2,  local/typeset/declare -p  without argument no longer
> outputs "declare -- -" when  local -  is used.
>
> But  local/typeset/declare -p -  still outputs "declare -- -" instead of
> "local -".
>
> bash-5.1$ a () { local -; local -p; declare -p -; typeset -p -;
> local -p - ;}
> bash-5.1$ a
> declare -- -
> declare -- -
> declare -- -
> declare -- -
>
> bash-5.2$ a () { local -; local -p; declare -p -; typeset -p -;
> local -p - ;}
> bash-5.2$ a
> local -
> declare -- -
> declare -- -
> declare -- -
>
>


Re: bash "extglob" needs to upgrade at least like zsh "kshglob"

2022-10-31 Thread Chet Ramey

On 10/29/22 1:50 AM, Martin D Kealey wrote:

This seems like a good reason to simply translate extglobs into regexes,
which should run in linear time, rather than put effort into building and
debugging a parallel implementation.


If someone wanted to do this, I would take a look at incorporating the
results, as long as it didn't add dependencies on, say, pcre or gnulib
regex.

Chet

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/




Re: Multiline editing breaks if the previous output doesn't end in newline

2022-10-31 Thread Alex fxmbsw7 Ratchev
where the cursor is ? some tput ansi code returns it .. but i guess u mean
bigger compatibility problems
does, readline, export its cursor assumptations ? like for dev'ing

On Mon, Oct 31, 2022, 16:46 Chet Ramey  wrote:

> On 10/30/22 9:40 PM, Oğuz wrote:
>
> > Yeah, or add a new prompt sequence (e.g. \N) that prints a newline only
> if
> > the cursor is not at column 0.
>
> There is no portable way to determine this.
>
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>  ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
>
>
>


Re: regex string ">(...)" in [[ ]] command recognize as process substitution

2022-10-31 Thread Chet Ramey

On 10/31/22 1:31 AM, Hyunho Cho wrote:


# this is an error
# [[ ]] command recognizes ">(.*)" as process substitution.
bash$ [[ $val =~ ((.*)<[^>]*>(.*)) ]] && echo yes  # Error !
bash$ .*: command not found


Yes, process substitution is one of the word expansions the pattern
undergoes (all words between [[ and ]] undergo the same set of word
expansions).


  The Second problem  #

This only happens in the terminal.

# 1. intentionally makes an error by removing escape "\>" to ">"
bash$ [[ $val =~ (.*)\ \<[^\>]*>\ (.*) ]] && echo yes
bash: syntax error in conditional expression: unexpected token `>'

# 2. fixed the error with \> escape, but the error continues
bash$ [[ $val =~ (.*)\ \<[^\>]*\>\ (.*) ]] && echo yes
bash: syntax error near unexpected token `$val'


This has already been fixed, the result of

https://savannah.gnu.org/support/index.php?110745




# 3. On the second try, the error goes away.
bash$ [[ $val =~ (.*)\ \<[^\>]*\>\ (.*) ]] && echo yes
yes

  The third problem  #

This also happens only in the terminal.
but very unexpectedly happens


I can't reproduce this using bash-5.2.2.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/




Re: Multiline editing breaks if the previous output doesn't end in newline

2022-10-31 Thread Chet Ramey

On 10/28/22 8:21 AM, Albert Vaca Cintora wrote:

Machine: All archs
OS: All OSes
Bash Version: All versions since I have memory

Description:
 When there's leftover output before the prompt (ie: when the
previous command output doesn't end in a new line), editing a
multi-line command from history doesn't correctly display what you
edit.


As I'm sure you'll hear again, readline assumes that it knows where the
physical cursor is on the line, and to assure this assumes it starts with
the cursor in column 0. The redisplay code assumes this. There is no
portable way for readline to determine the physical cursor location, so
it has to make assumptions.

There are various imperfect workarounds, but the easiest one is to hit
return.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/




Re: bash "extglob" needs to upgrade at least like zsh "kshglob"

2022-10-31 Thread Chet Ramey

On 10/30/22 6:32 AM, Oğuz wrote:


Or
(g) make the existing extglob code faster and avoid introducing more
complexity into the shell.


The extglob code has reasonable performance when it's asked to do the most
common thing: check whether a given null-terminated string matches a given
(possibly extended) pattern, anchored at start and end.

The problem arises when you want to support the leftmost-longest substring
match semantics required by pattern substitution. There's no
straightforward way to simply extend the model -- you have to implement
something new that supports those semantics to replace the simple way it's
done now.

If you want to stick with bash when performance for your use case becomes
unacceptable and eschew the (easy, simple, fast) sed workarounds, you're
going to be frustrated until something changes.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/




local/typeset/declare -p - outputs invalid declare -- -

2022-10-31 Thread Emanuele Torre
Since bash 5.2,  local/typeset/declare -p  without argument no longer
outputs "declare -- -" when  local -  is used.

But  local/typeset/declare -p -  still outputs "declare -- -" instead of
"local -".

bash-5.1$ a () { local -; local -p; declare -p -; typeset -p -;
local -p - ;}
bash-5.1$ a
declare -- -
declare -- -
declare -- -
declare -- -

bash-5.2$ a () { local -; local -p; declare -p -; typeset -p -;
local -p - ;}
bash-5.2$ a
local -
declare -- -
declare -- -
declare -- -