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

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

Closed
jsmeix opened this issue Aug 9, 2022 · 19 comments
Closed

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

jsmeix opened this issue Aug 9, 2022 · 19 comments

Comments

@jsmeix
Copy link
Member

jsmeix commented Aug 9, 2022

This is a follow up issue of
#2364
therein in particular
#2364 (comment)

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 jsmeix added the cleanup label Aug 9, 2022
@jsmeix jsmeix added this to the ReaR v2.8 milestone Aug 9, 2022
@jsmeix jsmeix self-assigned this Aug 9, 2022
@jsmeix
Copy link
Member Author

jsmeix commented Aug 9, 2022

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 added a commit that referenced this issue Aug 9, 2022
Use simpler and faster syntax STRING+=" additional words"
see #2848
jsmeix added a commit that referenced this issue Aug 9, 2022
Use simpler and faster syntax STRING+=" additional words"
see #2848
jsmeix added a commit that referenced this issue Aug 9, 2022
Use simpler and faster syntax STRING+=" additional words"
see #2848
@jsmeix
Copy link
Member Author

jsmeix commented Aug 9, 2022

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 added a commit that referenced this issue Aug 9, 2022
Use simpler and faster syntax STRING+=" additional words"
see #2848
jsmeix added a commit that referenced this issue Aug 9, 2022
Use simpler and faster syntax STRING+=" additional words"
see #2848
@jsmeix
Copy link
Member Author

jsmeix commented Aug 9, 2022

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
Copy link
Member Author

jsmeix commented Aug 9, 2022

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
Copy link
Member Author

jsmeix commented Aug 9, 2022

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 added a commit that referenced this issue Aug 9, 2022
Use simpler and faster syntax STRING+=" additional words"
see #2848
@jsmeix
Copy link
Member Author

jsmeix commented Aug 9, 2022

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
Copy link
Member Author

jsmeix commented Aug 9, 2022

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
Copy link
Member Author

jsmeix commented Aug 9, 2022

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
Copy link
Member Author

jsmeix commented Aug 9, 2022

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 added a commit that referenced this issue Aug 9, 2022
Use simpler and faster syntax STRING+=" additional words"
see #2848
@jsmeix
Copy link
Member Author

jsmeix commented Aug 9, 2022

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 added a commit that referenced this issue Aug 9, 2022
Use simpler and faster syntax STRING+=" additional words"
see #2848
jsmeix added a commit that referenced this issue Aug 9, 2022
Use simpler and faster syntax STRING+=" additional words"
see #2848
jsmeix added a commit that referenced this issue Aug 9, 2022
Use simpler and faster syntax STRING+=" additional words"
see #2848
jsmeix added a commit that referenced this issue Aug 9, 2022
Use simpler and faster syntax STRING+=" additional words"
see #2848
jsmeix added a commit that referenced this issue Aug 10, 2022
Use simpler and faster syntax STRING+=" additional words"
see #2848
@jsmeix
Copy link
Member Author

jsmeix commented Aug 10, 2022

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 added a commit that referenced this issue Aug 10, 2022
Use simpler and faster syntax STRING+=" additional words"
see #2848
jsmeix added a commit that referenced this issue Aug 10, 2022
Use simpler and faster syntax STRING+=" additional words"
see #2848
@jsmeix
Copy link
Member Author

jsmeix commented Aug 10, 2022

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 added a commit that referenced this issue Aug 10, 2022
Use simpler and faster syntax STRING+=" additional words"
see #2848
jsmeix added a commit that referenced this issue Aug 10, 2022
Use simpler and faster syntax STRING+=" additional words"
see #2848
jsmeix added a commit that referenced this issue Aug 10, 2022
Use simpler and faster syntax STRING+=" additional words"
see #2848
Additionally fixed indentation and cleaned up the logic
that "just returns if SELinux is not in use".
jsmeix added a commit that referenced this issue Aug 10, 2022
Use simpler and faster syntax STRING+=" additional words"
see #2848
@jsmeix
Copy link
Member Author

jsmeix commented Aug 10, 2022

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
Copy link
Member Author

jsmeix commented Aug 10, 2022

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 added a commit that referenced this issue Aug 10, 2022
Use simpler and faster syntax STRING+=" additional words"
see #2848
jsmeix added a commit that referenced this issue Aug 10, 2022
Use simpler and faster syntax STRING+=" additional words"
see #2848
@jsmeix
Copy link
Member Author

jsmeix commented Aug 10, 2022

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 added a commit that referenced this issue Aug 10, 2022
Use simpler and faster syntax STRING+=" additional words"
see #2848
@jsmeix
Copy link
Member Author

jsmeix commented Aug 10, 2022

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
Copy link
Member Author

jsmeix commented Aug 10, 2022

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
Copy link
Member Author

jsmeix commented Aug 10, 2022

All found cases that are listed in
#2848 (comment)
are now handled and all non-false-positives
should be fixed via
#2849

jsmeix added a commit that referenced this issue Aug 11, 2022
Use STRING+=" additional words" everywhere,
see #2848
@jsmeix
Copy link
Member Author

jsmeix commented Aug 11, 2022

With #2849 merged
this issue is done.

@jsmeix jsmeix closed this as completed Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant