zsh-workers
 help / color / mirror / code / Atom feed
From: "Andreas Kähäri" <andreas.kahari@abc.se>
To: "Wang, Yichao" <w.yichao@wustl.edu>
Cc: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: A bug on cat command for zsh
Date: Mon, 4 Dec 2023 09:01:25 +0100	[thread overview]
Message-ID: <ZW2HVRU3x-icS0SA@harpo.local> (raw)
In-Reply-To: <8C290B6D-2952-4CDC-9A90-64E990E25E38@wustl.edu>

On Mon, Dec 04, 2023 at 07:01:42AM +0000, Wang, Yichao wrote:
> Hi there,
> 
> I am using zsh 5.9 (x86_64-apple-darwin23.0) on MacOS.
> 
> The following command in zsh will cause severe damage by running forever into a dead loop.
> - when you accidentally mess up the redirection flows
> 
> ```bash
> touch 1.txt
> echo "anything" > 1.txt
> cat < 1.txt >> 1.txt
> ```
> 
> However, on Linux bash, this behavior is prohibited and hinted.
> 
> ```bash
> cat < 1.txt >> 1.txt
> cat: -: input file is output file
> ```
> 
> Best,
> Unknown name

Allowing the programmer to shoot themselves in the foot does not
seem like a bug to me.  Note that bash release 5.2.15 does not
seem to babysit the user in the way that you describe by default.
Rather, it's the coreutils implementation of cat that does this.

You may have two implementaions of cat on your system (it's possibly
a BSD system, or at least non-GNU system, with coreutils installed
alongside the native utilities).  Check with "type cat" in both shells
to see what cat is being picked up.


-- 
Andreas (Kusalananda) Kähäri
Uppsala, Sweden

.


  reply	other threads:[~2023-12-04  8:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-04  7:01 Wang, Yichao
2023-12-04  8:01 ` Andreas Kähäri [this message]
2023-12-04  8:30   ` Wang, Yichao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZW2HVRU3x-icS0SA@harpo.local \
    --to=andreas.kahari@abc.se \
    --cc=w.yichao@wustl.edu \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).