#2848 Issue closed: Use simpler and faster syntax STRING+=" additional words" everywhere

Labels: cleanup, fixed / solved / done

jsmeix opened issue at 2022-08-09 10:57:

This is a follow up issue of
https://github.com/rear/rear/issues/2364
therein in particular
https://github.com/rear/rear/issues/2364#issuecomment-616572074

In current GitHub master code I used the following
commands to get the variable names used in ReaR and
then search for varname="$varname in all scripts:

# varnames=$( find usr/sbin/rear usr/share/rear -type f | xargs egrep -ho '[[:alpha:]][[:alnum:]_]*=' | cut -d '=' -f1 | sort -u )

# for f in $( find usr/sbin/rear usr/share/rear -type f ) ; \
  do for varname in $varnames ; \
     do grep -ho "$varname=\"\$$varname[[:alnum:]_]*" $f && echo -e "$f\n" ; \
     done ; \
  done | tee /tmp/rear_varname=varname.found

Then I manually further processed /tmp/rear_varname=varname.found
(in particular sorted by script name) until I got

usr/sbin/rear
LOGFILE="$LOGFILE
LOGFILE="$LOGFILE

usr/share/rear/backup/NETFS/default/500_make_backup.sh
TAR_OPTIONS="$TAR_OPTIONS

usr/share/rear/build/default/501_check_ssh_keys.sh
removed_key_files="$removed_key_files

usr/share/rear/build/default/990_verify_rootfs.sh
missing_programs="$missing_programs
missing_required_programs="$missing_required_programs

usr/share/rear/conf/default.conf
HOSTNAME="$HOSTNAME

usr/share/rear/finalize/GNU/Linux/250_migrate_lun_wwid.sh
sed_script="$sed_script

usr/share/rear/finalize/GNU/Linux/280_migrate_uuid_tags.sh
sed_script="$sed_script

usr/share/rear/layout/prep-for-mount/default/540_generate_device_code.sh
type="$type

usr/share/rear/layout/prepare/GNU/Linux/100_include_partition_code.sh
d="$device_size
d="$device_size

usr/share/rear/layout/prepare/GNU/Linux/131_include_filesystem_code.sh
l="$label2
label="$label2

usr/share/rear/layout/prepare/GNU/Linux/136_include_btrfs_subvolumes_SLES_code.sh
s="$snapshot_subvolumes_devices_and_paths
snapshot_subvolumes_devices_and_paths="$snapshot_subvolumes_devices_and_paths
subvolume_path="$subvolume_path

usr/share/rear/layout/prepare/default/200_recreate_hpraid.sh
LAYOUT_CODE="$LAYOUT_CODE

usr/share/rear/layout/prepare/default/430_autoresize_all_partitions.sh
size="$size

usr/share/rear/layout/prepare/default/540_generate_device_code.sh
type="$type

usr/share/rear/layout/save/GNU/Linux/200_partition_layout.sh
flags="$flags
flags="$flags

usr/share/rear/layout/save/GNU/Linux/210_raid_layout.sh
layout="$layout_option_setting

usr/share/rear/layout/save/GNU/Linux/230_filesystem_layout.sh
btrfs_devices_and_mountpoints="$btrfs_devices_and_mountpoints
btrfs_subvolume_sles_setup_devices="$btrfs_subvolume_sles_setup_devices
read_filesystems_command="$read_filesystems_command

usr/share/rear/layout/save/GNU/Linux/280_multipath_layout.sh
libaio2add="$libaio2add

usr/share/rear/layout/save/GNU/Linux/280_multipath_layout.sh
s="$slaves
slaves="$slaves

usr/share/rear/layout/save/GNU/Linux/510_current_disk_usage.sh
egrep_pattern="$egrep_pattern

usr/share/rear/lib/_input-output-functions.sh
default_and_timeout="$default_and_timeout
not_yet_terminated_pids="$not_yet_terminated_pids
not_yet_terminated_pids="$not_yet_terminated_pids
read_options_and_arguments="$read_options_and_arguments
read_options_and_arguments="$read_options_and_arguments
read_options_and_arguments="$read_options_and_arguments
read_options_and_arguments="$read_options_and_arguments
read_options_and_arguments="$read_options_and_arguments
read_options_and_arguments="$read_options_and_arguments

usr/share/rear/lib/bootloader-functions.sh
file="$file
file="$file

usr/share/rear/lib/columns-functions.sh
columns="$columns
columns="$columns
value="$value

usr/share/rear/lib/global-functions.sh
path="$path
path="$path

usr/share/rear/lib/layout-functions.sh
disk="$disk
disk="$disk
file="$filename
file="$filename
l="$label
label="$label

usr/share/rear/prep/GNU/Linux/240_include_multipath_tools.sh
libaio2add="$libaio2add

usr/share/rear/prep/NETFS/default/070_set_backup_archive.sh
restore_archives_file_names="$restore_archives_file_names

usr/share/rear/prep/RSYNC/GNU/Linux/200_selinux_in_use.sh
KERNEL_CMDLINE="$KERNEL_CMDLINE

usr/share/rear/rescue/NETFS/default/610_save_capabilities.sh
exclude_directories="$exclude_directories

usr/share/rear/rescue/default/850_save_sysfs_uefi_vars.sh
UEFI_BOOTLOADER="$UEFI_BOOTLOADER

usr/share/rear/restore/DUPLICITY/default/400_restore_duplicity.sh
HOME="$HOME_TMP

usr/share/rear/restore/TSM/default/400_restore_with_tsm.sh
filespace="$filespace

usr/share/rear/restore/YUM/default/400_restore_packages.sh
repoList="$repoList

usr/share/rear/skel/default/etc/scripts/dhcp-setup-functions.sh
s="$s
s="$s
s="$s
s="$s

usr/share/rear/skel/default/etc/scripts/system-setup
egrep_pattern="$egrep_pattern

usr/share/rear/skel/default/etc/scripts/unlock-opal-disks
prompt="$prompt

usr/share/rear/verify/TSM/default/390_request_point_in_time_restore_parameters.sh
t="$tsm_restore_pit_time

This are only 67 found cases (in 37 files)
which is much less than I had expected
so I can clean up them with reasonable effort.
There are likely some false positives therein.
I will check that when looking at the code places.

jsmeix commented at 2022-08-09 11:11:

usr/sbin/rear
LOGFILE="$LOGFILE
LOGFILE="$LOGFILE

is a false positive because

# grep 'LOGFILE="$LOGFILE' usr/sbin/rear
RUNTIME_LOGFILE="$LOGFILE"
        RUNTIME_LOGFILE="$LOGFILE.lockless"

jsmeix commented at 2022-08-09 11:24:

usr/share/rear/conf/default.conf
HOSTNAME="$HOSTNAME

is a false positive because

# grep 'HOSTNAME="$HOSTNAME' usr/share/rear/conf/default.conf
# Example: RBME_HOSTNAME="$HOSTNAME-bcp"

jsmeix commented at 2022-08-09 11:29:

usr/share/rear/layout/prep-for-mount/default/540_generate_device_code.sh
type="$type

is a false positive because

# grep 'type="$type' usr/share/rear/layout/prep-for-mount/default/540_generate_device_code.sh
            willdotype="$type"

jsmeix commented at 2022-08-09 11:30:

usr/share/rear/layout/prepare/GNU/Linux/100_include_partition_code.sh
d="$device_size
d="$device_size

is a false positive because

# grep 'd="$device_size' usr/share/rear/layout/prepare/GNU/Linux/100_include_partition_code.sh
            end="$device_size"
                    end="$device_size"

jsmeix commented at 2022-08-09 11:31:

usr/share/rear/layout/prepare/GNU/Linux/131_include_filesystem_code.sh
l="$label2
label="$label2

is a false positive because

grep 'l="$label2' usr/share/rear/layout/prepare/GNU/Linux/131_include_filesystem_code.sh 
                    label="$label2"

jsmeix commented at 2022-08-09 11:37:

usr/share/rear/layout/prepare/GNU/Linux/136_include_btrfs_subvolumes_SLES_code.sh
...
subvolume_path="$subvolume_path

is a false positive because

# grep 'subvolume_path="$subvolume_path' usr/share/rear/layout/prepare/GNU/Linux/136_include_btrfs_subvolumes_SLES_code.sh
        default_subvolume_path="$subvolume_path"

jsmeix commented at 2022-08-09 11:39:

usr/share/rear/layout/prepare/default/200_recreate_hpraid.sh
LAYOUT_CODE="$LAYOUT_CODE

is a false positive because

# grep 'LAYOUT_CODE="$LAYOUT_CODE' usr/share/rear/layout/prepare/default/200_recreate_hpraid.sh
orig_LAYOUT_CODE="$LAYOUT_CODE"

jsmeix commented at 2022-08-09 11:40:

usr/share/rear/layout/prepare/default/430_autoresize_all_partitions.sh
size="$size

is a false positive because

# grep 'size="$size' usr/share/rear/layout/prepare/default/430_autoresize_all_partitions.sh
        oldsize="$size"

jsmeix commented at 2022-08-09 11:41:

usr/share/rear/layout/prepare/default/540_generate_device_code.sh
type="$type

is a false positive because

# grep 'type="$type' usr/share/rear/layout/prepare/default/540_generate_device_code.sh
            willdotype="$type"

jsmeix commented at 2022-08-09 11:44:

usr/share/rear/layout/save/GNU/Linux/210_raid_layout.sh
layout="$layout_option_setting

is a false positive because

# grep 'layout="$layout_option_setting' usr/share/rear/layout/save/GNU/Linux/210_raid_layout.sh
        test $layout_option_setting && layout="$layout_option_setting" || layout=""

jsmeix commented at 2022-08-10 10:17:

usr/share/rear/lib/bootloader-functions.sh
file="$file
file="$file

is a false positive because

# grep 'file="$file' usr/share/rear/lib/bootloader-functions.sh
            syslinux_file="$file"
            yaboot_file="$file"

jsmeix commented at 2022-08-10 10:25:

usr/share/rear/lib/layout-functions.sh
disk="$disk
disk="$disk
file="$filename
file="$filename
l="$label
label="$label

are false positives because

# grep 'disk="$disk' usr/share/rear/lib/layout-functions.sh
    current_disk="$disk"
    current_disk="$disk"

# grep 'file="$filename' usr/share/rear/lib/layout-functions.sh
    local saved_original_file="$filename.$START_DATE_TIME_NUMBER.$extension.$SAVED_ORIGINAL_FILE_SUFFIX"
    local saved_original_file="$filename.$START_DATE_TIME_NUMBER.$extension.$SAVED_ORIGINAL_FILE_SUFFIX"

# grep 'l="$label' usr/share/rear/lib/layout-functions.sh
    disk_label="$label"

jsmeix commented at 2022-08-10 11:13:

usr/share/rear/rescue/default/850_save_sysfs_uefi_vars.sh
UEFI_BOOTLOADER="$UEFI_BOOTLOADER

is a false positive because the code is

# Save the variables we need in recover mode into the rescue.conf file:
cat - <<EOF >> "$ROOTFS_DIR/etc/rear/rescue.conf"
USING_UEFI_BOOTLOADER=$USING_UEFI_BOOTLOADER
UEFI_BOOTLOADER="$UEFI_BOOTLOADER"
EOF

jsmeix commented at 2022-08-10 11:16:

usr/share/rear/restore/DUPLICITY/default/400_restore_duplicity.sh
HOME="$HOME_TMP

is a false positive.
FYI the code is

    HOME_TMP="$HOME"
    HOME="$DUPLICITY_TEMPDIR"
    ...
    [run programs with HOME="$DUPLICITY_TEMPDIR"]
    ...
    HOME="$HOME_TMP"

jsmeix commented at 2022-08-10 11:29:

usr/share/rear/skel/default/etc/scripts/dhcp-setup-functions.sh
s="$s
s="$s
s="$s
s="$s

is kept as is because most of what there is in
skel/default/etc/scripts/dhcp-setup-functions.sh
are coming from an old fedora-14 dhclient-script
(see the initial comment in dhcp-setup-functions.sh)
so it is mostly "foreign code" (i.e. not ReaR's own code)
and I don't like to mess around with "foreign code".

jsmeix commented at 2022-08-10 11:32:

usr/share/rear/skel/default/etc/scripts/unlock-opal-disks
prompt="$prompt

is a false positive because the code is

if ! password="$(use_plymouth && plymouth ask-for-password --prompt="$prompt")"; then

jsmeix commented at 2022-08-10 11:34:

usr/share/rear/verify/TSM/default/390_request_point_in_time_restore_parameters.sh
t="$tsm_restore_pit_time

is a false positive.
FYI the code is

test "$tsm_restore_pit_time" != "00:00:00" && TSM_DSMC_RESTORE_OPTIONS+=( -date=5 -pitt="$tsm_restore_pit_time" )

jsmeix commented at 2022-08-10 11:35:

All found cases that are listed in
https://github.com/rear/rear/issues/2848#issue-1333080530
are now handled and all non-false-positives
should be fixed via
https://github.com/rear/rear/pull/2849

jsmeix commented at 2022-08-11 12:43:

With https://github.com/rear/rear/pull/2849 merged
this issue is done.


[Export of Github issue for rear/rear.]