Bug 239761

Summary: Mk/Scripts/do-fetch.sh: `echo` in r507705 misses -n
Product: Ports & Packages Reporter: Ruslan Garipov <brigadir15>
Component: Ports FrameworkAssignee: Mathieu Arnold <mat>
Status: Open ---    
Severity: Affects Only Me CC: portmgr, ports-bugs
Priority: --- Keywords: needs-qa, regression
Version: Latest   
Hardware: Any   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=239293
Description Flags
Add missed -n none

Description Ruslan Garipov 2019-08-10 18:11:28 UTC
Created attachment 206422 [details]
Add missed -n

The `echo` added in r507705[1] misses -n.  This may cause fetching for a
port's file to be spread among several lines in the output of
`make fetch-list`.  It's difficult to process such result.

Please add missing -n to the `echo`.

[1] https://svnweb.freebsd.org/ports?view=revision&revision=507705
Comment 1 Mathieu Arnold freebsd_committer 2019-08-10 20:19:58 UTC
Well, fetch-list produces a shell script, what shell are you using that has problems with the output?
Comment 2 Ruslan Garipov 2019-08-11 04:20:33 UTC
(In reply to Mathieu Arnold from comment #1)
> what shell are you using

> problems with the output
I hadn't described my issue good enough, sorry, therefore you didn't
understand me.  There is no problem with the output itself.  A shell script
produced by fetch-list is correct.

The problem is that in a case described in PR 239293, a line in the
script, which download a file and which is usually "a text line" (there
are no newline characters within), becomes multiline "object".

For example:

$ cd /usr/ports/lang/rust
$ make fetch-list | cat -n
     1  mkdir -p /usr/ports/distfiles/rust && cd /usr/ports/distfiles/rust && { env /usr/bin/fetch -Fpr  -S 98707920 https://static.rust-lang.org/dist/rustc-1.36.0-src.tar.xz  || env /usr/bin/fetch -Fpr  -S 98707920 http://distcache.FreeBSD.org/ports-distfiles/rust/rustc-1.36.0-src.tar.xz  || echo "rustc-1.36.0-src.tar.xz" not fetched; }

There is no problem here: a fetching line is actually a "line".  But
here are the next lines:

     2  mkdir -p /usr/ports/distfiles/rust && cd /usr/ports/distfiles/rust && { mkdir -p "2019-05-23" &&
     3  env /usr/bin/fetch -Fpr  -S 73812596 -o 2019-05-23/rustc-1.35.0-x86_64-unknown-freebsd.tar.gz https://static.rust-lang.org/dist/2019-05-23/rustc-1.35.0-x86_64-unknown-freebsd.tar.gz  || mkdir -p "2019-05-23" &&
     4  env /usr/bin/fetch -Fpr  -S 73812596 -o 2019-05-23/rustc-1.35.0-x86_64-unknown-freebsd.tar.gz http://distcache.FreeBSD.org/local-distfiles/tobik/rust/2019-05-23/rustc-1.35.0-x86_64-unknown-freebsd.tar.gz  || mkdir -p "2019-05-23" &&
     5  env /usr/bin/fetch -Fpr  -S 73812596 -o 2019-05-23/rustc-1.35.0-x86_64-unknown-freebsd.tar.gz http://distcache.us-east.FreeBSD.org/local-distfiles/tobik/rust/2019-05-23/rustc-1.35.0-x86_64-unknown-freebsd.tar.gz  || mkdir -p "2019-05-23" &&
     6  env /usr/bin/fetch -Fpr  -S 73812596 -o 2019-05-23/rustc-1.35.0-x86_64-unknown-freebsd.tar.gz http://distcache.eu.FreeBSD.org/local-distfiles/tobik/rust/2019-05-23/rustc-1.35.0-x86_64-unknown-freebsd.tar.gz  || mkdir -p "2019-05-23" &&
     7  env /usr/bin/fetch -Fpr  -S 73812596 -o 2019-05-23/rustc-1.35.0-x86_64-unknown-freebsd.tar.gz http://distcache.us-west.FreeBSD.org/local-distfiles/tobik/rust/2019-05-23/rustc-1.35.0-x86_64-unknown-freebsd.tar.gz  || mkdir -p "2019-05-23" &&
     8  env /usr/bin/fetch -Fpr  -S 73812596 -o 2019-05-23/rustc-1.35.0-x86_64-unknown-freebsd.tar.gz http://distcache.FreeBSD.org/ports-distfiles/rust/2019-05-23/rustc-1.35.0-x86_64-unknown-freebsd.tar.gz  || echo "2019-05-23/rustc-1.35.0-x86_64-unknown-freebsd.tar.gz" not fetched; }
     {lines 9..22 are elided because they are similar to lines 2..8}

Because r507705 doesn't use `echo -n`, lines 2..7 end with
`mkdir -p "2019-05-23" &&`.  This is not an error, I just want to
collapse lines 2..8 into a single line.  Having oneline script for
fetching ``rustc-1.35.0-x86_64-unknown-freebsd.tar.gz'' (and all other
file) makes processing of the result much easy.