--no-color results in different output #875

Closed
opened 2024-05-25 19:01:09 +00:00 by sshaikh · 3 comments

What I'm trying to do and why

I'm struggling to port a borg diff command to borgmatic. Indicative example, in a bash script:

LIST=$(borgmatic list -c "$BORGMATIC_CONFIG" --repository "$REPOSITORY" |awk '{print $1}')

COUNTER=-2 #borgmatic adds two extra lines
for i in $LIST; do
        COUNTER=$((COUNTER+1))
done

i=$(echo "$LIST" | tail -n2 | head -1)
j=$(echo "$LIST" | tail -n3 | head -1)

echo "previous archive: $j"
echo "latest archive  : $i"

BORG_INFO=$(borgmatic info -c "$BORGMATIC_CONFIG" --json --repository "$REPOSITORY" --archive "$i")
BORG_DIFF=$(borgmatic -v 2 -c "$BORGMATIC_CONFIG" --repository "$REPOSITORY" borg diff ::$j $i)

Although the diff command works on the command line (when archives are specified), it fails with substitution with Archive archive1 does not exist Running with debug shows the following difference:

Command line:

Running arbitrary Borg command
BORG_CACHE_DIR=*** BORG_PASSCOMMAND=*** BORG_EXIT_CODES=*** BORG_REPO=*** ARCHIVE=*** borg diff --debug --show-rc ::archive2 archive1 >

Via script and substitution:

BORG_CACHE_DIR=*** BORG_PASSCOMMAND=*** BORG_EXIT_CODES=*** BORG_REPO=*** ARCHIVE=*** borg diff --debug --show-rc '::archive2' 'archive1' >

For some reason, single quotes are being introduced.

Steps to reproduce

No response

Actual behavior

No response

Expected behavior

No response

Other notes / implementation ideas

No response

borgmatic version

No response

borgmatic installation method

No response

Borg version

No response

Python version

No response

Database version (if applicable)

No response

Operating system and version

No response

### What I'm trying to do and why I'm struggling to port a borg diff command to borgmatic. Indicative example, in a bash script: ``` LIST=$(borgmatic list -c "$BORGMATIC_CONFIG" --repository "$REPOSITORY" |awk '{print $1}') COUNTER=-2 #borgmatic adds two extra lines for i in $LIST; do COUNTER=$((COUNTER+1)) done i=$(echo "$LIST" | tail -n2 | head -1) j=$(echo "$LIST" | tail -n3 | head -1) echo "previous archive: $j" echo "latest archive : $i" BORG_INFO=$(borgmatic info -c "$BORGMATIC_CONFIG" --json --repository "$REPOSITORY" --archive "$i") BORG_DIFF=$(borgmatic -v 2 -c "$BORGMATIC_CONFIG" --repository "$REPOSITORY" borg diff ::$j $i) ``` Although the diff command works on the command line (when archives are specified), it fails with substitution with `Archive archive1 does not exist` Running with debug shows the following difference: Command line: ``` Running arbitrary Borg command BORG_CACHE_DIR=*** BORG_PASSCOMMAND=*** BORG_EXIT_CODES=*** BORG_REPO=*** ARCHIVE=*** borg diff --debug --show-rc ::archive2 archive1 > ``` Via script and substitution: ``` BORG_CACHE_DIR=*** BORG_PASSCOMMAND=*** BORG_EXIT_CODES=*** BORG_REPO=*** ARCHIVE=*** borg diff --debug --show-rc '::archive2' 'archive1' > ``` For some reason, single quotes are being introduced. ### Steps to reproduce _No response_ ### Actual behavior _No response_ ### Expected behavior _No response_ ### Other notes / implementation ideas _No response_ ### borgmatic version _No response_ ### borgmatic installation method _No response_ ### Borg version _No response_ ### Python version _No response_ ### Database version (if applicable) _No response_ ### Operating system and version _No response_
sshaikh changed title from Unable to find archive when passed as variables to --no-color results in different output 2024-05-25 20:42:13 +00:00
Author

This is actually a red herring. The issue was using the output from a borgmatic list invocation provided output with ANSI codes. Apparently the --no-color flag should suppress color, which it does... but my output then changes:

# borgmatic list  -c config.yaml --repository repo

repo: Listing archives
archive1       Mon, 2018-12-31 20:42:30 [blah]
archive2       Tue, 2019-12-31 23:11:14 [blah]
...
# borgmatic list --no-color -c config.yaml --repository repo
ANSWER:borgmatic.actions.list:repo: Listing archives
ANSWER:borgmatic.execute:archive1       Mon, 2018-12-31 20:42:30 [blah]
ANSWER:borgmatic.execute:archive2       Tue, 2019-12-31 23:11:14 [blah]
This is actually a red herring. The issue was using the output from a `borgmatic list` invocation provided output with ANSI codes. Apparently the `--no-color` flag should suppress color, which it does... but my output then changes: ``` # borgmatic list -c config.yaml --repository repo repo: Listing archives archive1 Mon, 2018-12-31 20:42:30 [blah] archive2 Tue, 2019-12-31 23:11:14 [blah] ... ``` ``` # borgmatic list --no-color -c config.yaml --repository repo ANSWER:borgmatic.actions.list:repo: Listing archives ANSWER:borgmatic.execute:archive1 Mon, 2018-12-31 20:42:30 [blah] ANSWER:borgmatic.execute:archive2 Tue, 2019-12-31 23:11:14 [blah] ```
Author

Seems to be fixed here:

#863

Seems to be fixed here: https://projects.torsion.org/borgmatic-collective/borgmatic/issues/863
Owner

Glad to hear you've got this sorted now—and that an existing fix helped!

Glad to hear you've got this sorted now—and that an existing fix helped!
witten added the
question / support
label 2024-06-10 17:27:39 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#875
No description provided.