Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: A bug on cat command for zsh
- X-seq: zsh-workers 52370
- From: "Wang, Yichao" <w.yichao@xxxxxxxxx>
- To: Andreas Kähäri <andreas.kahari@xxxxxx>
- Cc: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Subject: Re: A bug on cat command for zsh
- Date: Mon, 4 Dec 2023 08:30:38 +0000
- Accept-language: en-US
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wustl.edu; dmarc=pass action=none header.from=wustl.edu; dkim=pass header.d=wustl.edu; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tABrBk8/jnWvIKe5Lqs+lerOKCy4ePF/N3zNGN2pqi0=; b=BU0SmZITuXA5xU5ZyZeUnyYXqfSHmfa1o03wTnJCIK32UOIWcsrVEbYtv25AObU0Oi9YkApevuPpixmr1vYy7hz9XTTrvBu4WnsjxQbGxJLA+dlpKDZnBxbJwVz/uZyU6mFtq2/R/aPD65PArwIlKMZoJnJEo9awdFOzpZnSu95R9bmrfeYe7iy+Y8Hhfz35MknaPe3mVo1BVV29utNmcSjcZ2KpUyT3bK60Vh43WjV+r48ddHb7py7lhbwErkzvL2i4UnN88uqBsgM2edulojXxp7Fbb5C+cBFC6tMqwWk+z1S/7O08FPY+k61fbvLOvKdO5OU9xy1dPFyA/bN2GQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AqLmm9mJBSKzwA2E/gIjr2Gx06/nqFiVvEIurApM5qJ4GRE0CjIZEgMaNpIhkZzphRySKrXs2kGbzA/ftCug3gDHmtjyDxhoMxijj0YQXhmOFx9IM6Llgdb0eADG0fQkNGFCBYCAsdhKm8Nq8oojw8clEYJvQeeoFCRWKIljYZ5S4VlC8tDWQ9FHlI98j/fJWPmTpn1nPY2zVgpAoqxtYb1PixwLXKK4UKsgHjnybYMa6HRKyl3qRIJ0xtzOYnenaHp718Q7s7cXtP9J4haNwRuN6lGD60G02E/9aApYOiqWHQXS98YmIllvov8K4ZrI6kgz4oGT9kJnkMJV6PDdKA==
- Archived-at: <https://zsh.org/workers/52370>
- In-reply-to: <ZW2HVRU3x-icS0SA@harpo.local>
- List-id: <zsh-workers.zsh.org>
- References: <8C290B6D-2952-4CDC-9A90-64E990E25E38@wustl.edu> <ZW2HVRU3x-icS0SA@harpo.local>
- Thread-index: AQHaJn+83o6HIQtrokuE45plwNI02rCYwyiAgAAIHIA=
- Thread-topic: A bug on cat command for zsh
Hi Andreas,
Thanks for pointing that out.
Yep, I see such different behavior (just by chance when playing around with command line) from MacOS(which is BSD system) and Linux (which follows GNU). I think you’re right they have different implementations of `cat`.
Have a nice day!
> On Dec 4, 2023, at 12:01 AM, Andreas Kähäri <andreas.kahari@xxxxxx> wrote:
>
> 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
>
> .
Messages sorted by:
Reverse Date,
Date,
Thread,
Author