Fossil Forum

Change output text when --dry-run is used to be (more) accurate
Login

Change output text when --dry-run is used to be (more) accurate

(1) By Heiko (scheit) on 2022-05-13 09:04:16 [source]

The output should be changed when using the '--dry-run' option.

For instance when using

$ fossil addremove --dry-run

the output should be

WOULD ADD  file.txt
would have added 1 file  (DRY-RUN)

instead of 

ADDED  file.txt
added 1 file

All the best and keep up the good work.

(2) By Stephan Beal (stephan) on 2022-05-13 10:11:35 in reply to 1 [link] [source]

The output should be changed when using the '--dry-run' option.

Many commands have a dry-run option and would be affected by such a change:

$ fossil help --everything | grep -c -- -dry-run
33

Changing the output adds a great deal of code for literally zero functional benefit and a debatable optic one (e.g. IMO the output should be identical for both modes). In fossil's many years, you're the first person to request this change, so presumably most users like the current approach just fine.

(3) By mark on 2022-05-13 10:34:21 in reply to 2 [link] [source]

so presumably most users like the current approach just fine.

I definitely prefer the current behaviour over the proposed change.

(6) By Heiko (scheit) on 2022-05-13 12:28:42 in reply to 2 [link] [source]

Well, if truth means anything, the statement 'ADDED...' is just wrong.

At least a program should say the truth. :)

And scripts relying on this out will also be fooled, since nothing was added, despite the statement.

If it helps, I can help to fix things up.

If you want a good example:

$ zfs destroy -nv pool/test-fs
would destroy pool/test-fs
would reclaim ...

Maybe just adding (DRY-RUN) at the end of each line OR at the end of the last line.  Or an additional line 'Nothing was changed. (DRY-RUN)'.

There I remembere another example:

$rsync --dry-run -v file.txt /tmp/
sent 39 bytes  received 19 bytes  116.00 bytes/sec
total size is 2,084  speedup is 35.93 (DRY RUN)


If a lot of output is produced, it is just not easy to remember if the last run was dry or not.

(8) By Stephan Beal (stephan) on 2022-05-13 13:08:54 in reply to 6 [link] [source]

Well, if truth means anything, the statement 'ADDED...' is just wrong.

As the help text usually says, --dry-run lists would would be done if --dry-run were not in effect. Truth is not sacrificed by keeping the same output in both cases.

And scripts relying on this out will also be fooled, since nothing was added, despite the statement.

We have never guaranteed any output for purposes of scripting, so that's a non-issue. Your proposed change makes scripting more difficult by adding an additional token to each line.

Or an additional line 'Nothing was changed. (DRY-RUN)'.

All (or almost all) commands which have dry-run mode have such a statement at the end. If you know of cases which don't do that, please point them out and we can add such a line. Changing every line out of output for the case of dry-run is simply a lot of unnecessary code.

(9) By Heiko (scheit) on 2022-05-13 13:15:49 in reply to 8 [link] [source]

That would be perfect.  Thanks!

'addremove' does not have it.

I hope I am not running on outdated version...

$ fossil version
This is fossil version 2.18 [c47fa2469e] 2022-02-23 13:54:02 UTC

(10) By Stephan Beal (stephan) on 2022-05-13 13:22:42 in reply to 9 [link] [source]

I hope I am not running on outdated version...

That's the latest release.

addremove now adds a line of output alerting the user about dry-run mode:

$ fossil addremove --dry-run | tail -5
ADDED  z.json
ADDED  z.json~
ADDED  zz.json
added 1351 files, deleted 0 files
Dry-run mode: no changes were made.

If you find other commands which don't have such a notice, please point them out.

(11) By Heiko (scheit) on 2022-05-13 13:39:42 in reply to 10 [link] [source]

Thanks a lot!

If I find other commands I will point them out.

(4) By Martin Gagnon (mgagnon) on 2022-05-13 10:54:14 in reply to 1 [link] [source]

Also, this kind of change would break people script which “colorify” the output by piping through sed or similar.

(5) By Florian Balmer (florian.balmer) on 2022-05-13 11:20:00 in reply to 1 [link] [source]

I even dare to say it's unusual to produce different output regardless of whether --dry-run is present:

$ patch -p0 < sample.patch --dry-run
patching file `sample.c'

$ patch -p0 < sample.patch
patching file `sample.c'

(7) By Heiko (scheit) on 2022-05-13 12:31:10 in reply to 5 [link] [source]

Truth matters :)

$ zfs destroy -nv pool/test-fs
would destroy pool/test-fs
would reclaim ...


$rsync --dry-run -v file.txt /tmp/
sent 39 bytes  received 19 bytes  116.00 bytes/sec
total size is 2,084  speedup is 35.93 (DRY RUN)