Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using '2>&1' or '2>&8' for 'select' clause results '-D' debug output on terminal #1431

Closed
jsmeix opened this issue Jul 26, 2017 · 7 comments
Closed
Assignees
Labels
Milestone

Comments

@jsmeix
Copy link
Member

jsmeix commented Jul 26, 2017

When rear is run in debugscript mode via 'rear -D'
using '2>&1' or '2>&8' for 'select' clauses
results 'set -x' debug output on the user's terminal.

For example in
layout/prepare/default/300_map_disks.sh
there is

    select choice in "${possible_targets[@]}" "Do not map disk." ; do
        n=( $REPLY ) # trim blanks from reply
        let n-- # because bash arrays count from 0
        if [ "$n" = "${#possible_targets[@]}" ] || [ "$n" -lt 0 ] || [ "$n" -ge "${#possible_targets[@]}" ] ; then
            LogPrint "Disk $(get_device_name $dev) not automatically replaced."
        else
            LogPrint "Disk $choice chosen as replacement for $(get_device_name $dev)."
            add_mapping "$dev" "$choice"
        fi
        break
    done 0<&6 1>&7 2>&8

which results longer possibly disturbing
'set -x' debug output on the user's terminal:

Comparing disks.
Device sda has size 26843545600, 21474836480 expected
Switching to manual disk layout configuration.
Original disk /dev/sda does not exist in the target system. Please choose an appropriate replacement.
++ select choice in '"${possible_targets[@]}"' '"Do not map disk."'
1) /dev/sda
2) Do not map disk.
#? 1
++ n=($REPLY)
++ let n--
++ '[' 0 = 1 ']'
++ '[' 0 -lt 0 ']'
++ '[' 0 -ge 1 ']'
+++ get_device_name /dev/sda
+++ local name=sda
+++ name=sda
+++ [[ -n sda ]]
+++ BugIfError 'Empty string passed to get_device_name'
+++ ((  0 != 0  ))
+++ local device dev_number mapper_number
+++ [[ -d /sys/block/sda ]]
+++ [[ -r /sys/block/sda/dm/name ]]
+++ dev_number=8:0
+++ for device in '/dev/mapper/*'
++++ dmsetup info -c --noheadings -o major,minor control
+++ mapper_number=
+++ '[' 8:0 = '' ']'
+++ [[ sda =~ ^mapper/ ]]
++++ readlink /dev/sda
+++ my_dm=
+++ name=sda
+++ echo /dev/sda
+++ return 1
++ LogPrint 'Disk /dev/sda chosen as replacement for /dev/sda.'
++ Log 'Disk /dev/sda chosen as replacement for /dev/sda.'
+++ date '+%Y-%m-%d %H:%M:%S.%N '
++ local 'timestamp=2017-07-26 13:07:10.557339060 '
++ test 1 -gt 0
++ echo '2017-07-26 13:07:10.557339060 Disk /dev/sda chosen as replacement for /dev/sda.'
2017-07-26 13:07:10.557339060 Disk /dev/sda chosen as replacement for /dev/sda.
++ Print 'Disk /dev/sda chosen as replacement for /dev/sda.'
++ test 1
++ echo -e 'Disk /dev/sda chosen as replacement for /dev/sda.'
Disk /dev/sda chosen as replacement for /dev/sda.
++ add_mapping /dev/sda /dev/sda
++ echo '/dev/sda /dev/sda'
++ break
This is the disk mapping table:
    /dev/sda /dev/sda

FYI: Here the main 'set -x' output comes from the
evaluation of the fixed $(get_device_name $dev)
inside the 'select' clause (where $dev does not change)
so that this should have better been done before
and outside of the 'select' clause.

For comparison how it looks without '-D'

Comparing disks.
Device sda has size 26843545600, 21474836480 expected
Switching to manual disk layout configuration.
Original disk /dev/sda does not exist in the target system. Please choose an appropriate replacement.
1) /dev/sda
2) Do not map disk.
#? 1
2017-07-26 12:50:57.705512775 Disk /dev/sda chosen as replacement for /dev/sda.
Disk /dev/sda chosen as replacement for /dev/sda.
This is the disk mapping table:
    /dev/sda /dev/sda

Via #1391
I implemented using the original fds
for actually intended user input/output
in particular for whole 'select' clauses like

    select choice in WORDS ; do
        COMMANDS
    done 0<&6 1>&7 2>&8

so that nowadays '2>&8' is used.

Before the code had been like

    select choice in WORDS ; do
        COMMANDS
    done 2>&1

where '2>&1' was needed because the expanded WORDS are
printed on stderr which is by default redirected into the log file
so that '2>&1' was needed to get the intended user output
of the 'select' clause on the user's terminal but then
also 'set -x' debug output appears on the user's terminal.

Therefore for ReaR v2.3 as many as possible 'select' (and 'read')
commands should be replaced by the UserInput function
cf. #1399
and this would - by the way - also fix this issue here.

@jsmeix jsmeix added cleanup enhancement Adaptions and new features minor bug An alternative or workaround exists labels Jul 26, 2017
@jsmeix jsmeix added this to the ReaR v2.3 milestone Jul 26, 2017
@jsmeix jsmeix self-assigned this Jul 26, 2017
@gdha
Copy link
Member

gdha commented Nov 27, 2017

@jsmeix is this issue not fixed in the meantime?

@jsmeix jsmeix modified the milestones: ReaR v2.3, ReaR v2.4 Nov 28, 2017
@jsmeix
Copy link
Member Author

jsmeix commented Nov 28, 2017

It is fixed where I replaced 'select' by UserInput()
but not where I used

select select choice in ...
    ...
done 0<&6 1>&7 2>&8

or

read ... 0<&6 1>&7 2>&8

so that it is not yet fixed really everywhere.

But this is nothing that must be done for the ReaR 2.3 release
because it was this way all the time before so that there are
no regressions.

I move the milestone to ReaR 2.4. to fix the remaining cases
(as time provides).

FYI:
A quick search for 'select choice in' in the scripts found
verify/RBME/default/540_choose_backup.sh
and
verify/USB/NETFS/default/540_choose_backup_archive.sh
where in the latter I had already implemented
a special workaround some time ago via

{ set +x ; } 2>/dev/null
select choice in
    ...
done 0<&6 1>&7 2>&8
apply_bash_flags_and_options_commands "$DEFAULT_BASH_FLAGS_AND_OPTIONS_COMMANDS"

@gdha
Copy link
Member

gdha commented May 10, 2018

@jsmeix I think this issue is as good fixed as it possible can be, no?

@jsmeix jsmeix modified the milestones: ReaR v2.4, ReaR v2.5 May 14, 2018
@jsmeix jsmeix removed the minor bug An alternative or workaround exists label May 14, 2018
@jsmeix
Copy link
Member Author

jsmeix commented May 14, 2018

@gdha
I think it is not yet fixed at all places where it can be fixed
so that the issue is still not sufficiently done
but there is nothing urgent here
so that I postpone it for the next ReaR 2.5
and I remove the "minor bug" because I think
nothing goes actually wrong as it is now.

@jsmeix jsmeix modified the milestones: ReaR v2.5, ReaR v2.6 Feb 26, 2019
@jsmeix
Copy link
Member Author

jsmeix commented Feb 26, 2019

This issue can wait => postponing to "ReaR v2.6" milestone.

@jsmeix jsmeix modified the milestones: ReaR v2.6, ReaR v2.7 Apr 29, 2020
@jsmeix
Copy link
Member Author

jsmeix commented Apr 29, 2020

This issue can wait even longer => postponing to "ReaR v2.7" milestone.

@github-actions
Copy link

github-actions bot commented Jul 1, 2020

Stale issue message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants