meta data for this page
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| linux:bash [2022/12/01 15:26] – niziak | linux:bash [2026/05/05 12:13] (current) – niziak | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Bash ====== | ====== Bash ====== | ||
| - | ===== rerun as other user ===== | + | |
| + | ===== re-run | ||
| <code bash> | <code bash> | ||
| if [ $UID == 0 ]; then | if [ $UID == 0 ]; then | ||
| - | exec su -c " | + | exec su -c " |
| fi | fi | ||
| </ | </ | ||
| Line 104: | Line 105: | ||
| </ | </ | ||
| - | ===== include/ | ||
| - | Possible test scenario: | ||
| - | - call using from another directory full path / | ||
| - | - add / | ||
| - | - create symlink to script and call using symlink. Check for relative and absolute symlinks. | ||
| - | - it should work also if it is sourced " | ||
| - | |||
| - | The best is to create setup/ | ||
| - | |||
| - | Another solutions: | ||
| - | <code bash> | ||
| - | #!/bin/sh | ||
| - | MY_DIR=$(dirname $(readlink -f $0)) | ||
| - | $MY_DIR/ | ||
| - | </ | ||
| - | |||
| - | <code bash> | ||
| - | DIR=$( cd "$( dirname " | ||
| - | </ | ||
| - | |||
| - | <code bash> | ||
| - | # Works correctly if script is sourced from another one | ||
| - | DIR=" | ||
| - | </ | ||
| - | |||
| - | <code bash> | ||
| - | cur_file=" | ||
| - | cur_dir=" | ||
| - | </ | ||
| - | |||
| - | '' | ||
| - | An array variable whose members are the source filenames where the | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | '' | ||