Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #15011
| Path | csiph.com!3.us.feeder.erje.net!feeder.erje.net!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail |
|---|---|
| From | Eduardo A. Bustamante López <dualbus@gmail.com> |
| Newsgroups | gnu.bash.bug |
| Subject | Re: "COMMAND 2>&1 > PATH" doesn't work |
| Date | Sun, 30 Dec 2018 13:40:27 -0800 |
| Lines | 100 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.6590.1546206035.1284.bug-bash@gnu.org> (permalink) |
| References | <CAC5x5Q8bc1EV1QgZDTFxEm6hfz1qPgTnfgQ78+FhF_y2bMkn6A@mail.gmail.com> |
| NNTP-Posting-Host | lists.gnu.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 8bit |
| X-Trace | usenet.stanford.edu 1546206035 25208 208.118.235.17 (30 Dec 2018 21:40:35 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| Cc | bug-bash@gnu.org |
| To | Dušan Kreheľ <dusankrehel@gmail.com> |
| Envelope-to | bug-bash@gnu.org |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=xYrqCot79sOM0H+FbZSgrcswAJDJUKjsJhyxtZQmUBw=; b=XAQYkE59Olfm09Y3Dvd25f/Q9SVb/4m8F2prrzdf6ybFTSh8Gf3/ocdPoLgATLFT+n kEBLpEc9NnuDai/+bTVglVU6QP2qYmFT1H5MbIHGEhpzZZz1FYCIhfehN/qCPo9APjfT l5XtZJ1zk7ZPs1AhMVkR9/0r3SJ9C24HmJa898YwNVveG17YMUvt4JJZamvIU6WWO7RH hS6qS7NHPm02yZlKjA8w2BKaJlAWc3YU7objnoRYV+S8vXj7Jbk91/en8yX9Hh7WQK7V C1/Nte2hiqb3jfv/s7YT1Jv5p4YhkFplcaHWweccSNzIIYQ4D8WqPAMlpDLDk3cIPqKd +qWQ== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=xYrqCot79sOM0H+FbZSgrcswAJDJUKjsJhyxtZQmUBw=; b=IUejAWpfF+o0Obe+0AwUvWyVlUOGptEoOCgkn+e3C3+IKTQfKbImJzi6a+D7sVgvSn 3Dc5zzHQNquCQCJR63Qa2qq3z3LoHo1KTAQbDVtrJyV67SLlQLYZn6XUaeqE2aAhC7jf vkdu++eC6VAqrNqkWoNqWNGc27mzFFdtpmlV/g4QMtDzJWxTOUpRsHBS81EFWWgS+qrN k91zeviZcPN/miM/z6m14tqasNJff9gwV28SpdkrPXluFs1l5NqB69OGxq0obeUOqkkl UAk26M/H2kwyZ5SNfuDRk/OLxjPAzCMbtH30ZOUr5QeYPbl/XK834BDEK4VbXksba/ud 1j9g== |
| X-Gm-Message-State | AA+aEWYOugS8EdcX/gC5EF4UABiNhzvWwq0wuD3ztdZyCpet7kzKNZ6n sTPFKU2h/hPYZbGHggeUuecrmg5W |
| X-Google-Smtp-Source | AFSGD/WTF6BFjc5qmEDQp8a0TZQGxS7+M+zL+5w5PYwL5Q4Y7TwoMVxrOHlewA4xsA7vu7TrHUtzQQ== |
| X-Received | by 2002:a62:c613:: with SMTP id m19mr36272847pfg.207.1546206030044; Sun, 30 Dec 2018 13:40:30 -0800 (PST) |
| Mail-Followup-To | Dušan Kreheľ <dusankrehel@gmail.com>, bug-bash@gnu.org |
| Content-Disposition | inline |
| In-Reply-To | <CAC5x5Q8bc1EV1QgZDTFxEm6hfz1qPgTnfgQ78+FhF_y2bMkn6A@mail.gmail.com> |
| User-Agent | Mutt/1.10.1 (2018-07-13) |
| X-detected-operating-system | by eggs.gnu.org: Genre and OS details not recognized. |
| X-Received-From | 2607:f8b0:4864:20::542 |
| X-BeenThere | bug-bash@gnu.org |
| X-Mailman-Version | 2.1.21 |
| Precedence | list |
| List-Id | Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org> |
| List-Unsubscribe | <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe> |
| List-Archive | <http://lists.gnu.org/archive/html/bug-bash/> |
| List-Post | <mailto:bug-bash@gnu.org> |
| List-Help | <mailto:bug-bash-request@gnu.org?subject=help> |
| List-Subscribe | <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe> |
| Xref | csiph.com gnu.bash.bug:15011 |
Show key headers only | View raw
On Sun, Dec 30, 2018 at 10:10:42PM +0100, Dušan Kreheľ wrote: > Hello. > > If I try in bash this command ex. "rmdir somethingA > somethingA.out > 2>&1" work right. But, if I try "rmdir somethingB 2>&1 > > somethingB.out" that work wrong. > > That work's wrong in Bash version 4.4.23(1) and too in 5.0.0(1)-rc1: Why do you expect these two to behave in the same way? They are clearly distinct operations. COMMAND >FILE 2>&1 is not the same as: COMMAND 2>&1 >FILE The order of redirections matter, they are processed left-to-right. Let's look at these examples in more detail. Example 1. COMMAND >FILE 2>&1 Let's break it down into tokens and see what happens at each step. a) COMMAND file descriptor 0 -> terminal file descriptor 1 -> terminal file descriptor 2 -> terminal This is the "normal" state in an interactive shell, the three standard file descriptors (input: 0, output: 1, and error: 2) are pointing to the terminal device. b) >FILE file descriptor 0 -> terminal file descriptor 1 -> FILE file descriptor 2 -> terminal The `>FILE' redirection is processed, causing file descriptor 1 (standard output) to be directed to the file named `FILE'. c) 2>&1 file descriptor 0 -> terminal file descriptor 1 -> FILE file descriptor 2 -> FILE The `2>&1' redirection is processed, causing file descriptor 2 (the `2>' bit) to be directed to "wherever-fd1-points-to" (i.e. the `&1' bit). FD1 currently points to `FILE', so FD2 is updated to point to `FILE' too. VS Example 2. COMMAND 2>&1 FILE a) COMMAND file descriptor 0 -> terminal file descriptor 1 -> terminal file descriptor 2 -> terminal same as example 1. b) 2>&1 file descriptor 0 -> terminal file descriptor 1 -> terminal file descriptor 2 -> terminal * no change The `2>&1' redirection is processed, causing file descriptor 2 to be directed to "wherever-fd1-points-to". FD1 currently points to the terminal. FD2 points to the terminal too, so it stays the same. c) >FILE file descriptor 0 -> terminal file descriptor 1 -> FILE file descriptor 2 -> terminal The `>FILE' redirection is processed, causing file descriptor 1 (standard output) to be directed to the file named `FILE'. So, this is not a bug. It's the expected behavior of redirections. If you want to read more about it, I recommend: - https://mywiki.wooledge.org/BashFAQ/055 - http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_07
Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread
Re: "COMMAND 2>&1 > PATH" doesn't work Eduardo A. Bustamante López <dualbus@gmail.com> - 2018-12-30 13:40 -0800
csiph-web