Re: Having an alias and a function with the same name leads to some sort of recursion

2023-02-20 Thread Chet Ramey
On 2/18/23 12:50 AM, Oğuz İsmail Uysal wrote:     $ alias foo='cat

Re: Having an alias and a function with the same name leads to some sort of recursion

2023-02-17 Thread Oğuz İsmail Uysal
On 2/18/23 2:05 AM, Chet Ramey wrote: If the shell reads an unquoted word in the right position, it checks the word to see if it matches an alias name. If it matches, the shell replaces the word [in the input] with the alias value, and reads that value as if it had been read [from the input] inst

Re: Having an alias and a function with the same name leads to some sort of recursion

2023-02-17 Thread Robert Elz
Date:Sat, 18 Feb 2023 12:21:49 +1000 From:Martin D Kealey Message-ID: | Both of these are clearly wrong, Yes, which is why POSIX is changing. I am concerned less about bash (and other shell) doc about the details of all of this, more useful to suggest that users

Re: Having an alias and a function with the same name leads to some sort of recursion

2023-02-17 Thread Martin D Kealey
On 2/14/23 2:58 PM, Dale R. Worley wrote: > Though I think by "keyword" he means "reserved word". > Yes, though in my defense, the bash man page liberally uses the term "keyword". On Fri, 17 Feb 2023 at 01:14, Chet Ramey wrote > I think the issue is that he's applying a grammar interpretation

Re: Having an alias and a function with the same name leads to some sort of recursion

2023-02-17 Thread Chet Ramey
On 2/17/23 11:36 AM, Dale R. Worley wrote: I think this change covers the case we're talking about, clarifies the second sentence a bit, and seems to be well-aligned with the more detailed truth: Aliases allow a string to be substituted for a word when it is used as the first wo

Re: Having an alias and a function with the same name leads to some sort of recursion

2023-02-17 Thread alex xmb ratchev
plus if an alias definition ends with a space , when in use , further aliases may get resolved ( substituded , before parsing code further ) On Fri, Feb 17, 2023, 5:37 PM Dale R. Worley wrote: > Chet Ramey writes: > > On 2/14/23 2:58 PM, Dale R. Worley wrote: > Looking at the manual page,

Re: Having an alias and a function with the same name leads to some sort of recursion

2023-02-17 Thread Dale R. Worley
Chet Ramey writes: > On 2/14/23 2:58 PM, Dale R. Worley wrote: Looking at the manual page, it says ALIASES Aliases allow a string to be substituted for a word when it is used as the first word of a simple command. >> >> Martin suggested (but II

Re: Having an alias and a function with the same name leads to some sort of recursion

2023-02-16 Thread alex xmb ratchev
On Thu, Feb 16, 2023, 4:14 PM Chet Ramey wrote: > On 2/14/23 2:58 PM, Dale R. Worley wrote: > >>> Looking at the manual page, it says > >>> > >>> ALIASES > >>> Aliases allow a string to be substituted for a word when it > is used as > >>> the first word of a simple command.

Re: Having an alias and a function with the same name leads to some sort of recursion

2023-02-16 Thread Chet Ramey
On 2/14/23 2:58 PM, Dale R. Worley wrote: Looking at the manual page, it says ALIASES Aliases allow a string to be substituted for a word when it is used as the first word of a simple command. Martin suggested (but IIUC didn't sent to this list): "Beginning of a simple c

Re: Having an alias and a function with the same name leads to some sort of recursion

2023-02-14 Thread alex xmb ratchev
On Tue, Feb 14, 2023, 8:58 PM Dale R. Worley wrote: > >> Looking at the manual page, it says > >> > >> ALIASES > >>Aliases allow a string to be substituted for a word when it is > used as > >>the first word of a simple command. > > Martin suggested (but IIUC didn't sent to th

Re: Having an alias and a function with the same name leads to some sort of recursion

2023-02-14 Thread Dale R. Worley
>> Looking at the manual page, it says >> >> ALIASES >>Aliases allow a string to be substituted for a word when it is used >> as >>the first word of a simple command. Martin suggested (but IIUC didn't sent to this list): > "Beginning of a simple command" should probably be re

Re: Having an alias and a function with the same name leads to some sort of recursion

2023-02-07 Thread Robert Elz
Date:Tue, 7 Feb 2023 14:35:54 -0500 From:Chet Ramey Message-ID: | On 2/7/23 12:33 PM, Dale R. Worley wrote: (That was 7 Feb, not 2 July...) | > That makes it clear why the second case behaves as it does. But my | > reading of the definition of "simple command

Re: Having an alias and a function with the same name leads to some sort of recursion

2023-02-07 Thread Chet Ramey
On 2/7/23 12:33 PM, Dale R. Worley wrote: ALIASES Aliases allow a string to be substituted for a word when it is used as the first word of a simple command. That makes it clear why the second case behaves as it does. But my reading of the definition of "simple commands" i

Re: Having an alias and a function with the same name leads to some sort of recursion

2023-02-07 Thread Dale R. Worley
Robert Elz writes: > | Aliases are not used in bash scripts, unless bash is invoked in POSIX > | compatibility mode, or the "expand_aliases" shopt is turned on. > > I think that's what must have happened ... the infinite loop of > echo commands suggests that the function definition > > c

Re: Having an alias and a function with the same name leads to some sort of recursion

2023-01-02 Thread Robert Elz
Date:Mon, 2 Jan 2023 10:02:45 -0500 From:Greg Wooledge Message-ID: | Aliases are not used in bash scripts, unless bash is invoked in POSIX | compatibility mode, or the "expand_aliases" shopt is turned on. I think that's what must have happened ... the infinite l

Re: Having an alias and a function with the same name leads to some sort of recursion

2023-01-02 Thread Greg Wooledge
On Mon, Jan 02, 2023 at 10:13:28AM +0200, Yuri Kanivetsky wrote: > Hi, > > #!/usr/bin/env bash > set -eu > alias cmd=echo Aliases are not used in bash scripts, unless bash is invoked in POSIX compatibility mode, or the "expand_aliases" shopt is turned on.

Having an alias and a function with the same name leads to some sort of recursion

2023-01-02 Thread Yuri Kanivetsky
Hi, #!/usr/bin/env bash set -eu alias cmd=echo cmd() { echo "$@" } set -x cmd a b c $ ./a.sh + echo a b c + echo a b c ... + echo a b c + echo a b c Command terminated Sounds like a bug. I'd expect it to notice the alias, turn "cmd a b c" into "echo a b c" and print the letters. Regards, Y