savannah-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Savannah-cvs] [733] add useful code snippet


From: iank
Subject: [Savannah-cvs] [733] add useful code snippet
Date: Wed, 3 Jan 2024 05:17:28 -0500 (EST)

Revision: 733
          
http://svn.savannah.gnu.org/viewvc/?view=rev&root=administration&revision=733
Author:   iank
Date:     2024-01-03 05:17:27 -0500 (Wed, 03 Jan 2024)
Log Message:
-----------
add useful code snippet

Modified Paths:
--------------
    trunk/sviki/fsf/bash-style-guide.mdwn

Modified: trunk/sviki/fsf/bash-style-guide.mdwn
===================================================================
--- trunk/sviki/fsf/bash-style-guide.mdwn       2024-01-03 10:17:23 UTC (rev 
732)
+++ trunk/sviki/fsf/bash-style-guide.mdwn       2024-01-03 10:17:27 UTC (rev 
733)
@@ -530,3 +530,12 @@
 ```
 \[[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
 ```
+
+cd to the directory of the script file. For example, if data files are
+stored in that directory.
+
+```
+this_file="$(readlink -f -- "${BASH_SOURCE[0]}")"
+readonly this_file this_dir="${this_file%/*}"
+cd "$this_dir"
+```




reply via email to

[Prev in Thread] Current Thread [Next in Thread]