zsh-workers
 help / color / mirror / code / Atom feed
* Random file creation in zsh shell.
@ 2023-06-17  2:03 LitHack
  2023-06-17  4:55 ` Fwd: " LitHack
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: LitHack @ 2023-06-17  2:03 UTC (permalink / raw)
  To: zsh-workers


[-- Attachment #1.1: Type: text/plain, Size: 317 bytes --]

There is a way to create a random file in zsh shell by which we could hide
any of our data in it.

Command: <>=()

Explanation: By running this command we can create a random file in /tmp
directory and each time it create new file with random name having "zsh" in
front of them. According to me this is bug.

Thanks.

[-- Attachment #1.2: Type: text/html, Size: 447 bytes --]

[-- Attachment #2: Screenshot from 2023-06-17 07-15-57.png --]
[-- Type: image/png, Size: 108540 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Fwd: Random file creation in zsh shell.
  2023-06-17  2:03 Random file creation in zsh shell LitHack
@ 2023-06-17  4:55 ` LitHack
  2023-06-17  6:36 ` Roman Perepelitsa
  2023-06-19  0:24 ` Bart Schaefer
  2 siblings, 0 replies; 5+ messages in thread
From: LitHack @ 2023-06-17  4:55 UTC (permalink / raw)
  To: zsh-workers


[-- Attachment #1.1: Type: text/plain, Size: 496 bytes --]

---------- Forwarded message ---------
From: LitHack <lithack0@gmail.com>
Date: Sat, Jun 17, 2023, 7:33 AM
Subject: Random file creation in zsh shell.
To: <zsh-workers@zsh.org>


There is a way to create a random file in zsh shell by which we could hide
any of our data in it.

Command: <>=()

Explanation: By running this command we can create a random file in /tmp
directory and each time it create new file with random name having "zsh" in
front of them. According to me this is bug.

Thanks.

[-- Attachment #1.2: Type: text/html, Size: 917 bytes --]

[-- Attachment #2: Screenshot from 2023-06-17 07-15-57.png --]
[-- Type: image/png, Size: 108540 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Random file creation in zsh shell.
  2023-06-17  2:03 Random file creation in zsh shell LitHack
  2023-06-17  4:55 ` Fwd: " LitHack
@ 2023-06-17  6:36 ` Roman Perepelitsa
  2023-06-19  0:21   ` Bart Schaefer
  2023-06-19  0:24 ` Bart Schaefer
  2 siblings, 1 reply; 5+ messages in thread
From: Roman Perepelitsa @ 2023-06-17  6:36 UTC (permalink / raw)
  To: LitHack; +Cc: zsh-workers

On Sat, Jun 17, 2023 at 4:04 AM LitHack <lithack0@gmail.com> wrote:
>
> There is a way to create a random file in zsh shell by which we could hide any of our data in it.
>
> Command: <>=()

I found this surprising.

    % =true < =()
    % ls /tmp/zsh*
    /tmp/zshMw5YZq

Is it expected for `=true < =()` to leave a temporary file behind?

With the builtin `true` the behavior matches my expectation:

    % true < =()
    % ls /tmp/zsh*
    zsh: no matches found: /tmp/zsh*

Another example that leaves a temporary file behind:

    % ( exec true ) < =()

All of these work as expected, meaning that they don't leave a
temporary file behind:

    % () { =true } < =()
    % ( =true ) < =()
    % ( true ) < =()

Roman.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Random file creation in zsh shell.
  2023-06-17  6:36 ` Roman Perepelitsa
@ 2023-06-19  0:21   ` Bart Schaefer
  0 siblings, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2023-06-19  0:21 UTC (permalink / raw)
  To: Roman Perepelitsa; +Cc: LitHack, zsh-workers

On Fri, Jun 16, 2023 at 11:36 PM Roman Perepelitsa
<roman.perepelitsa@gmail.com> wrote:
>
> On Sat, Jun 17, 2023 at 4:04 AM LitHack <lithack0@gmail.com> wrote:
> >
> > There is a way to create a random file in zsh shell by which we could hide any of our data in it.
>
> Is it expected for `=true < =()` to leave a temporary file behind?

When an =(...) temp file is created, the parent shell assigns removal
to the child job, which is supposed to happen when the job exits.  In
the case of a shell function or builtin, this works as expected.  In
the case of an external command or a subshell that performs a "tail
call optimization" like your "( exec true )" example, the thread
that's meant to remove the temp file is replaced by a new process and
the exit-handler that would remove the file is lost.

I've spent quite a while on and off in the past prodding at the code
in exec.c to try to convince it that when there is a temp file present
it should skip the execve() and instead fork()/wait() to be able to
remove the file at the end, but have never got it to work without
breaking something else.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Random file creation in zsh shell.
  2023-06-17  2:03 Random file creation in zsh shell LitHack
  2023-06-17  4:55 ` Fwd: " LitHack
  2023-06-17  6:36 ` Roman Perepelitsa
@ 2023-06-19  0:24 ` Bart Schaefer
  2 siblings, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2023-06-19  0:24 UTC (permalink / raw)
  To: LitHack; +Cc: zsh-workers

On Fri, Jun 16, 2023 at 7:04 PM LitHack <lithack0@gmail.com> wrote:
>
> There is a way to create a random file in zsh shell by which we could hide any of our data in it.

There are lots of ways to do this if you are able to run commands in
the shell.  Who is the "our" that is "hiding" data, and why does that
matter?


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-06-19  0:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-17  2:03 Random file creation in zsh shell LitHack
2023-06-17  4:55 ` Fwd: " LitHack
2023-06-17  6:36 ` Roman Perepelitsa
2023-06-19  0:21   ` Bart Schaefer
2023-06-19  0:24 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).