From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY,URIBL_SBL_A autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 7637 invoked from network); 8 Aug 2021 14:05:04 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 8 Aug 2021 14:05:04 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1628431504; b=V/wnB3+iFTjW74RkxUwmy7s9jlu7WlTaCX2KvH5lDYU342EQi30mZmcuLzdua2xhRBctkHspXF y6CMF7SeFZI5JfPzFvVQDixCAvHPnaF7YUObl29JhZ0pbAuqpcYnMcLh0PUPZYN23PteRqZ4yO ZFRm25UmufqHcsHVAr9NmrAaTX3bJjNmMQcqxFWoJkFuKXHrG7XY13da2pfi6SSxr12xLoWeBA 4NFdnwCGEkt4hiUMkHFF6S+0ev4Mky6bKjlTa8H4KysrC97/BNCrF0w/F7key39N7Stc++JjfX 0aDxPUd19sr/7AhHEwqlnSRQ9HZnMBim5Qry7qr9UDpFzw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay1-d.mail.gandi.net) smtp.remote-ip=217.70.183.193; dmarc=none header.from=chazelas.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1628431504; bh=neXdnEQ2GC2cvRSLD1LySd6gOjKRPz9JQu3QqFfDDHo=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:DKIM-Signature; b=HjEzZYX+J2Lj7+0jZuQ8iZilUB0iS1H8Tir2uwjXNcPxs/CwPxPTNwrKLe36jR0MtNI3RiupaL XdYptK/nhiecFO/k8KdK0yYSII2PzHRyDq0KV6knULlB62EjEeOA7Cy/WGbAQQ0V4KI8gjrgWU 1NWdYX60R7hXa6EjfpmW6r8LAcUMa0LKuS0JXomRUtvl35u32ZTtP5lPMqiO53RLA4shCU9QXS DEL/FzA5640iaarmebO7cwahnHNvOADEaMZoHKyuHdAlxuoMWu3/ZomDhcNLlQYSFfMYtYw7rK ogXKECSsRgjTH8ePq5hhSd4P9NtSQtPuQftAX4CJpchtqA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=p6MvIUiVNJ/lRNRBRt0+nVtZfokCd0RKPnMWHjjMnIY=; b=QPw5baTn8s4M2jWT2KI/TplRzf Klm1T1OH/fm3D+gII2kH20QHpp/YkJNMMIXuqpN/xucSue8PyUx+tdmYMmch9EdJvTvVZrmsaFPPq WkSrnC/HIbrcIt4hT5ACzXdMTh8D6glDmRxkVV6fKPCxTFMTl+4uEzN3pe/Fhcr0kNBtQPlkWvPrW VJrFGcmfCmcAHC9G+6kSZ5qCKih0UrOWAXNdxUep9vv3axX0xsbnNxh3FCz1FF0U2p/rlxWAl7PAM 3k3oEt0rX+jILMfxcJ6O8pJR4Us/PERzSTQcmbYIYsNuWC4tuVSipWmtlUquqj8dCkHY3G/0382tg lIsGodow==; Received: from authenticated user by zero.zsh.org with local id 1mCjQE-000GzM-OR; Sun, 08 Aug 2021 14:05:02 +0000 Authentication-Results: zsh.org; iprev=pass (relay1-d.mail.gandi.net) smtp.remote-ip=217.70.183.193; dmarc=none header.from=chazelas.org; arc=none Received: from relay1-d.mail.gandi.net ([217.70.183.193]:18133) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1mCjPw-000Gh8-Nq; Sun, 08 Aug 2021 14:04:45 +0000 Received: (Authenticated sender: stephane@chazelas.org) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 1E049240005; Sun, 8 Aug 2021 14:04:42 +0000 (UTC) Date: Sun, 8 Aug 2021 15:04:42 +0100 From: Stephane Chazelas To: Mikael Magnusson Cc: David Milum , zsh-workers@zsh.org Subject: Re: read -r flag not working on 5.8.1 Message-ID: <20210808140442.bm2g3qmjtxmr5ybb@chazelas.org> Mail-Followup-To: Mikael Magnusson , David Milum , zsh-workers@zsh.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Seq: 49262 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: 2021-08-08 07:59:20 +0200, Mikael Magnusson: [...] > >> Hello, seems like the -r (raw mode) flag which should prevent it from > >> interpreting backslashes is not working? My understanding is the > >> following > >> example shouldn't clear the "CLEAR" part. I can also demonstrate with new > >> lines. > >> > >> $ read -r TEST > >> asd\c CLEAR > >> $ echo $TEST > >> asd > >> $ zsh --version > >> zsh 5.8 (x86_64-pc-linux-gnu) > > Your problem is not read, but echo. Try the above with echo -E $TEST > instead and you will see the read command is fine. [...] More precisely, to print the contents of a scalar variable verbatim followed by a newline character in zsh: echo -E - $var # zsh only print -r - $var # zsh print -r -- $var # zsh print -r - "$var" # zsh/ksh printf '%s\n' "$var" # POSIX echo -En "$var"$'\n' # zsh/bash and a few other echo # implementations (but for bash, not if # both the xpg_echo and posix options are # enabled). cat << EOF # Bourne/POSIX $var EOF cat <<< "$var" # zsh and a few other shells See also zmodload zsh/system syswrite -- "$var"$'\n' || syserror -p failed: $ERRNO for a raw interface to the write() system call. And btw, to read a line into a variable, the syntax is IFS= read -r var (in zsh or any other POSIX shell, though only zsh can read lines containing NUL bytes). See https://unix.stackexchange.com/questions/65803/why-is-printf-better-than-echo https://unix.stackexchange.com/questions/209123/understanding-ifs-read-r-line -- Stephane