fast-cli icon indicating copy to clipboard operation
fast-cli copied to clipboard

Redirect output is broken

Open capedra opened this issue 3 years ago • 3 comments

Since this option does not work for me, because it still prints several lines on my output, this is what I did for Cron to work fine running this Bash script:

#!/bin/sh
speedtest=$(/usr/local/bin/node /usr/local/lib/node_modules/fast-cli/cli.js --single-line -u | tail -n 1 | awk '{ print substr( $0, 17 ) }')
result=$(date +'%d/%m/%Y %T ')$(echo $speedtest)
echo $result >> speedtest.txt

capedra avatar Nov 15 '21 08:11 capedra

Can you show an example of where it prints more than a single line? If it does, it's a bug.

sindresorhus avatar Nov 15 '21 14:11 sindresorhus

@sindresorhus Hello Sindre. Sorry about my delay. The issue consists when you output the response of the command to some file. On the terminal you can see one line only, but when you redirect the output to the txt file, you can see several blank lines, white spaces, carriage returns and line breaks. Anyway, I did this Bash script to include the current date/time and only the last line (the one that matters) of the fast-cli command, eliminating all these unnecessary characters. I'm attaching the output file of the bash script above that I developed: speedtest.txt Thank you very much and keep improving this project since it works a lot better than the speedtest-cli!!!

capedra avatar Nov 24 '21 08:11 capedra

Seems like we broke redirected output in https://github.com/sindresorhus/fast-cli/commit/08b3cf782aa715510617ec9d51577dd8147367c3.

sindresorhus avatar Nov 24 '21 10:11 sindresorhus