Skip to content

Commit

Permalink
kw: replace every "#!/bin/bash" shebang with "#!/usr/bin/env bash"
Browse files Browse the repository at this point in the history
The usual "#!/bin/bash" may not work for some linux distributions.
Replace it with "#!/usr/bin/env bash"

kworkflow, being a bash-written project, requires the use of shebangs to define the interpreter environment where kw is run. Nowadays, the scripts contain the shebang "#!/bin/bash", which works normally for most of the distros.
There are, however, some exceptions, such as NixOS, where there is no /bin/bash (bash is located in /nix/store). Using workflow on these types of distros may not be
smooth, since the user is required to run kw commands preceded by bash or manually modify the code.

Closes: kworkflow#1089

Signed-off-by: Marcelo Mendes Spessoto Junior <[email protected]>
  • Loading branch information
MarceloSpessoto committed May 1, 2024
1 parent fbf7535 commit efdcc76
Show file tree
Hide file tree
Showing 68 changed files with 74 additions and 68 deletions.
2 changes: 1 addition & 1 deletion database/migrate_legacy_data_20220101.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# This file handles the migration of legacy user data, from the old directories and files
# storage, to the new database model
Expand Down
6 changes: 6 additions & 0 deletions documentation/content/codingstyle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,12 @@ Good::

rsync --verbose --recursive dir1 dir2

Declaring shebangs
------------------

Avoid using "#!/bin/bash" when writing new bash files. This usual shebang may not work for
some linux distributions that don't follow FHS, such as NixOS. Use "#!/usr/bin/env bash" instead.

Conclusion
----------

Expand Down
2 changes: 1 addition & 1 deletion kw
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

KWORKFLOW=${KWORKFLOW:-'kw'}

Expand Down
2 changes: 1 addition & 1 deletion run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

. ./src/lib/kw_include.sh --source-only
include './tests/unit/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion scripts/kwreview.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

declare -gA opt
declare -ga analysed_files
Expand Down
2 changes: 1 addition & 1 deletion setup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
KW_LIB_DIR='src'
. 'src/lib/kw_include.sh' --source-only
include "${KW_LIB_DIR}/lib/kwio.sh"
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/config_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './tests/unit/utils.sh'
include './tests/integration/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/device_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './tests/unit/utils.sh'
include './tests/integration/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/kw_version_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/lib/kwio.sh'
include './tests/unit/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/podman/clone_and_install_kw.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# The primary purpose of this file is to install kw's dependencies in the image
# we will built. This will save up time when installing the local copy of KW in
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/utils.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/lib/kwio.sh'

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/backup_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/backup.sh'
include './src/lib/kwlib.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/build_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/build.sh' > /dev/null
include './tests/unit/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/codestyle_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/codestyle.sh'
include './tests/unit/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/config_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/config.sh'
include './tests/unit/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/debug_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/debug.sh'
include './tests/unit/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/deploy_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/deploy.sh'
include './tests/unit/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/device_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/device_info.sh'
include './tests/unit/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/diff_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/diff.sh'
include './tests/unit/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/drm_plugin_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/plugins/subsystems/drm/drm.sh'
include './src/lib/kwlib.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/explore_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './tests/unit/utils.sh'
include './src/explore.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/help_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './tests/unit/utils.sh'
include './src/help.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/init_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/init.sh'
include './tests/unit/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/kernel_config_manager_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/kernel_config_manager.sh'
include './tests/unit/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/kw_dash.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './tests/unit/utils.sh'

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/kw_db_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './tests/unit/utils.sh'
include './src/lib/kw_db.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/kw_env_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/kw_env.sh'
include './tests/unit/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/kw_remote_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/kw_remote.sh'
include './tests/unit/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/kw_ssh_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/kw_ssh.sh'
include './tests/unit/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/kw_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './tests/unit/utils.sh'
unset -v KW_LIB_DIR # to be able to test the developer mode
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/lib/dialog_ui_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
include './src/lib/dialog_ui.sh'
include './tests/unit/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/lib/kw_config_loader_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './tests/unit/utils.sh'
include './src/lib/kw_config_loader.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/lib/kw_include_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './tests/unit/utils.sh'

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/lib/kw_string_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/lib/kw_string.sh'
include './tests/unit/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/lib/kw_time_and_date_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/lib/kw_time_and_date.sh'
include './tests/unit/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/lib/kwio_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './tests/unit/utils.sh'
include './src/lib/kwio.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/lib/kwlib_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/maintainers.sh'
include './src/lib/kwlib.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/lib/lore_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/lib/lore.sh'
include './tests/unit/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/lib/remote_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/lib/remote.sh'
include './src/lib/kwlib.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/lib/signal_manager_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/lib/signal_manager.sh'
include './tests/unit/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/lib/statistics_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/lib/statistics.sh'
include './tests/unit/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/lib/web_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/lib/web.sh'
include './tests/unit/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/mail_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/mail.sh'
include './tests/unit/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/maintainers_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/maintainers.sh'
include './tests/unit/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/patch_hub_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/patch_hub.sh'
include './tests/unit/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/permissions_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './tests/unit/utils.sh'

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/plugins/kernel_install/arch_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/plugins/kernel_install/utils.sh'
include './src/plugins/kernel_install/arch.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/plugins/kernel_install/bootloader_utils_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/plugins/kernel_install/bootloader_utils.sh'
include './tests/unit/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/plugins/kernel_install/debian_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/plugins/kernel_install/utils.sh'
include './src/plugins/kernel_install/debian.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/plugins/kernel_install/fedora_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/plugins/kernel_install/utils.sh'
include './src/plugins/kernel_install/fedora.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/plugins/kernel_install/grub_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/plugins/kernel_install/utils.sh'
include './src/plugins/kernel_install/grub.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/plugins/kernel_install/rpi_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/plugins/kernel_install/utils.sh'
include './src/plugins/kernel_install/rpi_bootloader.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/plugins/kernel_install/utils_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# We load utils in the oneTimeSetUp() to ensure we can replace some kw functions
include './tests/unit/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/plugins/kw_mail/to_cc_cmd_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './tests/unit/utils.sh'

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/pomodoro_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/pomodoro.sh'
include './src/lib/kw_db.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/report_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/report.sh'
include './src/lib/kw_db.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/samples/tracing/kw_main_file_mock
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# This is a mock to test the injection of tracing code into kw main file

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/scripts/profiler_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './scripts/profiler.sh' > '/dev/null' 2>&1
include './tests/unit/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/self_update_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/self_update.sh'
include './tests/unit/utils.sh'
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/tracing/tracing_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './tracing/tracing.sh'
include './tests/unit/utils.sh'
Expand Down Expand Up @@ -45,7 +45,7 @@ function test_sync_main_kw_file_with_tracing()
output=$(< "${bin}/${kw_path}")
expected=$(
cat << 'EOF'
#!/bin/bash
#!/usr/bin/env bash

# This is a mock to test the injection of tracing code into kw main file

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/ui/patch_hub/latest_patchsets_from_mailing_list.sh'
include './tests/unit/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/ui/patch_hub/lore_mailing_lists_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/ui/patch_hub/lore_mailing_lists.sh'
include './tests/unit/utils.sh'
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/ui/patch_hub/patch_hub_core_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/ui/patch_hub/patch_hub_core.sh'
include './tests/unit/utils.sh'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

include './src/ui/patch_hub/patchset_details_and_actions.sh'
include './tests/unit/utils.sh'
Expand Down
Loading

0 comments on commit efdcc76

Please sign in to comment.