Re: No form commsub if last token ends with & or ;

2023-06-20 Thread alex xmb ratchev
On Mon, Jun 19, 2023, 20:16 Chet Ramey  wrote:

> On 6/18/23 4:59 AM, Grisha Levit wrote:
> > On Sunday, May 28, 2023, Grisha Levit  wrote:
> >
> >> Missing final `;':
> >>
> >> "$BASH" --pretty-print <<< $'${ : \;;}'
> >> ${ : \; }
> >>
> >
> > The latest set of fixes to this code solves these cases but others  have
> > issues:
> >
> > $ bash --pretty-print <<<$'${ : \;;\n}'
> > ${ : \; }
> > $ bash --pretty-print <<<$'${ : \;\n\n}'
> > ${ : \; }
> > $ bash --pretty-print <<<$'${ : \&;\n}'
> > ${ : \& }
> > $ bash --pretty-print <<<$'${ : \&;\n\n}'
> > ${ : \& }
> >
> > I think it might be ok to just have print_comsub handle adding the final
> > semicolon when needed instead of trying to add it after the fact in
> > parse_comsub?
>
> I'll think about it. The advantage of doing it in parse_comsub is that
> the parser has access to the token history, instead of having to intuit
> it lexically. Along the lines of what Martin Kealey said, it's easy to
> output a newline if the last token the parser read before the closing `}'
> was a newline, and that solves this problem.
>

if u wanna .. keep users newspaces and stuff
like some 1 : 1 code print , u d just need to save the text/data between
keywords
thats not pretty print ..

awk has it , or gawk , with split and patsplit , saves the 'in between' in
an arr ( seps )
sadly this important pieces didnt make it to without function calling

-- 
> ``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/
>
>
>


Fwd: Command execution by creating file.

2023-06-20 Thread LitHack
-- Forwarded message -
From: LitHack 
Date: Wed, Jun 21, 2023, 7:31 AM
Subject: Command execution by creating file.
To: 


Special character '*' can be used to execute the command.
We have to just create a directory and make a file of any character or word
and then make alias of the command which we want to execute assigned with
created file. Now just type the * in terminal and you will that the command
be executed.
But why this happens, * (special character) is used for auto completion and
if used as alone it should just print the name of file why it's execute the
file name as command.
Command:mkdir dir;cd dir:<>file;alias file=ls -l;*


Re: Fwd: Command execution by creating file.

2023-06-20 Thread Greg Wooledge
On Wed, Jun 21, 2023 at 08:22:19AM +0530, LitHack wrote:
> Special character '*' can be used to execute the command.

"Doctor, it hurts when I bend my arm like this!"



Re: Fwd: Command execution by creating file.

2023-06-20 Thread Lawrence Velázquez
On Tue, Jun 20, 2023, at 10:52 PM, LitHack wrote:
> -- Forwarded message -
> From: LitHack 
> Date: Wed, Jun 21, 2023, 7:31 AM
> Subject: Command execution by creating file.
> To: 
>
>
> Special character '*' can be used to execute the command.
> We have to just create a directory and make a file of any character or word
> and then make alias of the command which we want to execute assigned with
> created file. Now just type the * in terminal and you will that the command
> be executed.

This is not true.  Alias expansion occurs before filename expansion.

> But why this happens, * (special character) is used for auto completion and
> if used as alone it should just print the name of file why it's execute the
> file name as command.

This is not true either.  What makes you think that it should "just
print the name of file"?

> Command:mkdir dir;cd dir:<>file;alias file=ls -l;*

Did you actually run these commands?  They don't agree with you.

bash-5.2$ mkdir dir
bash-5.2$ cd dir
bash-5.2$ <> file
bash-5.2$ alias file='ls -l'
bash-5.2$ *
Usage: file [bcCdEhikLlNnprsvzZ0] [-e test] [-f namefile] [-F 
separator] [-m magicfiles] [-M magicfiles] file...
   file -C -m magicfiles
Try `file --help' for more information.

-- 
vq



Re: Command execution by creating file.

2023-06-20 Thread Martin D Kealey
The assertion "should just print the name of [the] file" is mistaken.

You seem to have conflated autocompletion (which occurs while typing,
usually in response to the TAB key, which is prior to parsing a command
which in turn is prior to invoking it) with filename generation (which
occurs as a late phase of command invocation).

A command consists of a number of words, any of which can be generated by
command completion; the first word is not special in this respect.

(What would be surprising is if an alias were expanded after filename
generation. I suspect your minimal proof case is incomplete.)

-Martin


Re: Fwd: Command execution by creating file.

2023-06-20 Thread LitHack
Sorry instead of alias we have to use the function.

Corrected command: mkdir dir;cd dir;<>file;file()bash;*

Thanks and regards.

On Wed, Jun 21, 2023, 8:46 AM Lawrence Velázquez  wrote:

> On Tue, Jun 20, 2023, at 10:52 PM, LitHack wrote:
> > -- Forwarded message -
> > From: LitHack 
> > Date: Wed, Jun 21, 2023, 7:31 AM
> > Subject: Command execution by creating file.
> > To: 
> >
> >
> > Special character '*' can be used to execute the command.
> > We have to just create a directory and make a file of any character or
> word
> > and then make alias of the command which we want to execute assigned with
> > created file. Now just type the * in terminal and you will that the
> command
> > be executed.
>
> This is not true.  Alias expansion occurs before filename expansion.
>
> > But why this happens, * (special character) is used for auto completion
> and
> > if used as alone it should just print the name of file why it's execute
> the
> > file name as command.
>
> This is not true either.  What makes you think that it should "just
> print the name of file"?
>
> > Command:mkdir dir;cd dir:<>file;alias file=ls -l;*
>
> Did you actually run these commands?  They don't agree with you.
>
> bash-5.2$ mkdir dir
> bash-5.2$ cd dir
> bash-5.2$ <> file
> bash-5.2$ alias file='ls -l'
> bash-5.2$ *
> Usage: file [bcCdEhikLlNnprsvzZ0] [-e test] [-f namefile] [-F
> separator] [-m magicfiles] [-M magicfiles] file...
>file -C -m magicfiles
> Try `file --help' for more information.
>
> --
> vq
>


Re: Fwd: Command execution by creating file.

2023-06-20 Thread Dennis Williamson
On Tue, Jun 20, 2023 at 10:55 PM LitHack  wrote:

> Sorry instead of alias we have to use the function.
>
> Corrected command: mkdir dir;cd dir;<>file;file()bash;*
>
> Thanks and regards.
>


You don't need the function either.

mkdir dir; cd dir; touch bash; *


-- 
Visit serverfault.com to get your system administration questions answered.


Re: Fwd: Command execution by creating file.

2023-06-20 Thread Lawrence Velázquez
On Tue, Jun 20, 2023, at 11:55 PM, LitHack wrote:
> Sorry instead of alias we have to use the function.

There is still no bug.  You simply do not understand how the shell
language works.

(There's nothing wrong with that, of course, and questions are
welcome at .  But your "bug reports" have all
been baseless.)

> Corrected command: mkdir dir;cd dir;<>file;file()bash;*

You didn't run these commands either.

bash-5.2$ mkdir dir
bash-5.2$ cd dir
bash-5.2$ <>file
bash-5.2$ file()bash
bash: syntax error near unexpected token `bash'

Please don't send broken code, forcing readers to waste their time
figuring out what you actually meant.  (This particular code is
easy to fix, but that's besides the point.)

-- 
vq