Re: declare -f does not output esac pattern correctly

2024-02-28 Thread Martin D Kealey
On Tue, 27 Feb 2024 at 18:48, Oğuz wrote: > On Tuesday, February 27, 2024, Martin D Kealey > wrote: > >> I've been thinking for a while now that POSIX made a mistake when it >> permitted ';;' before the closing 'esac'. >> > > I think that decision was made before POSIX. Besides it's handy when

Re: declare -f does not output esac pattern correctly

2024-02-27 Thread Chet Ramey
On 2/27/24 6:23 AM, Emanuele Torre wrote: On Tue, Feb 27, 2024 at 04:10:06PM +0700, Robert Elz wrote: Date:Tue, 27 Feb 2024 00:50:46 +0100 From:Emanuele Torre Message-ID: | To use esac as a pattern you need to use the (esac) syntax, Or quote it

Re: declare -f does not output esac pattern correctly

2024-02-27 Thread Chet Ramey
On 2/26/24 6:50 PM, Emanuele Torre wrote: Hello. I have noticed that declare -f does not output valid code when a pattern is `esac'. Thanks for the report. More precisely, if the first word in the pattern list is the literal string "esac". "The grammar shows that reserved words can be used

Re: declare -f does not output esac pattern correctly

2024-02-27 Thread Emanuele Torre
On Tue, Feb 27, 2024 at 12:23:41PM +0100, Emanuele Torre wrote: > On Tue, Feb 27, 2024 at 04:10:06PM +0700, Robert Elz wrote: > > Date:Tue, 27 Feb 2024 00:50:46 +0100 > > From:Emanuele Torre > > Message-ID: > > > > | To use esac as a pattern you need to use the

Re: declare -f does not output esac pattern correctly

2024-02-27 Thread Emanuele Torre
On Tue, Feb 27, 2024 at 04:10:06PM +0700, Robert Elz wrote: > Date:Tue, 27 Feb 2024 00:50:46 +0100 > From:Emanuele Torre > Message-ID: > > | To use esac as a pattern you need to use the (esac) syntax, > > Or quote it > > 'esac') > > (or similar). > > kre

Re: declare -f does not output esac pattern correctly

2024-02-27 Thread Robert Elz
Date:Tue, 27 Feb 2024 00:50:46 +0100 From:Emanuele Torre Message-ID: | To use esac as a pattern you need to use the (esac) syntax, Or quote it 'esac') (or similar). kre

Re: declare -f does not output esac pattern correctly

2024-02-27 Thread Oğuz
On Tuesday, February 27, 2024, Martin D Kealey wrote: > > I've been thinking for a while now that POSIX made a mistake when it > permitted ';;' before the closing 'esac'. > I think that decision was made before POSIX. Besides it's handy when generating case clauses on the fly, you may not

Re: declare -f does not output esac pattern correctly

2024-02-27 Thread Martin D Kealey
I've been thinking for a while now that POSIX made a mistake when it permitted ';;' before the closing 'esac'. If ';;' were prohibited there, then the parser could be sure that the next word after every ';;' would be a pattern, even if it looks like 'esac'. But as things stand, there's an

declare -f does not output esac pattern correctly

2024-02-26 Thread Emanuele Torre
Hello. I have noticed that declare -f does not output valid code when a pattern is `esac'. To use esac as a pattern you need to use the (esac) syntax, but declare -f does not use it, and ends up generating invalid code. a () { case $1 in hi) echo hi ;; (esac) echo esac ;;