Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Naive read mistake
- X-seq: zsh-users 27848
- From: Perry Smith <pedz@xxxxxxxxxxxxxxxx>
- To: Zsh-Users List <zsh-users@xxxxxxx>
- Subject: Naive read mistake
- Date: Thu, 16 Jun 2022 11:29:17 -0500
- Arc-authentication-results: i=1; rspamd-848669fb87-k2xd5; auth=pass smtp.auth=a2hosting smtp.mailfrom=pedz@xxxxxxxxxxxxxxxx
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1655396959; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: dkim-signature; bh=YOzxceBiP9DflLlycBJZSVlI57sATD9kCVC2iuTkdUg=; b=MOt/zYVuJN0oasmW2E4lvPHZawuFv/rZECqCiK7Mf0Xwfq9J7+h3hmnYrs6RyIfYsnUpI2 6hxy8W/+mN2dI2O0A33TPvVcRLl1AELtoQKc8DbCSMEHGcce4fFOgIottg5PXlHmd1x0h7 3nRNsCg71E5nDL2aRmAy0vEo2ya+Ur3P6NOSax7P8u41kIDXqbYFnSRlXpgILFu9Duq6Hc NHPRIg0fIMdrj7i2fACrXjjVI6E1NbyL8hosCNmS0gjbjDZgFI8lUHTowAQA0r3fTmuWtJ Z0k0oLhdwF02lgi1Ff/5c+/2Tf5bdXXYlbbnkyFG3q0sTJcX+qtFobkPwJSAdQ==
- Arc-seal: i=1; s=arc-2022; d=mailchannels.net; t=1655396959; a=rsa-sha256; cv=none; b=i1iu05v6rCthldryQ9BHReujMDL/kr+QPRYudSKIY+l0WAKYjQWnXOvqEElCHECYJGFKnk XYv+pjaXTB8lFtTz1MHjfoWBgdorRaS9T9eNGOgLzXfYQvUirUHBJg1LqP5dzR8B9BttJE koxOTEQPbFiMYXkH/6fMxCiWG/B9XKiw+fJbPSlmO1CNWziGlKdg0Qyj4ffVa79gkg0B54 FA56KWctpuzpti6AiqyrZWVISY5+yHOZRz9euYIR+uYDK+B3mTRAqa2V0LaKSlJ0E/IUim HSsv5ALnFj+I+8KiVBQwxWM/mJJBj5tbA6c3y2dkpCZLul7unrDbCTt2lw1qhg==
- Archived-at: <https://zsh.org/users/27848>
- List-id: <zsh-users.zsh.org>
I’ve been seriously confused with a simple function that is reading the output from a curl https command. I finally figured out the issue and everything is working as documented but thought I would tell of my saga.
From the documentation for “read”:
> The value (exit status) of read is 1 when an end-of-file is
> encountered, or when -c or -l is present and the command is not
> called from a compctl function, or as described for -q. Otherwise
> the value is 0.
I had the common loop:
while read line ; do … done
For me in this instance, the loop is not executed on the last line because it is not terminated with a newline. line is set but the read returns 1 since it hit EOF. All this is correct as far as I can tell but I just wasn’t expecting it.
I’m using curl with “-i” to an HTTPS API returning headers and JSON. The function I was having problems with was to separate the headers from the JSON output. So this issue might come up for others.
Thank you for your time,
Perry
Attachment:
signature.asc
Description: Message signed with OpenPGP
Messages sorted by:
Reverse Date,
Date,
Thread,
Author