summaryrefslogtreecommitdiffstats
path: root/nix-utils.sh
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2015-05-29 22:26:27 +0200
committerMatthias Beyer <mail@beyermatthias.de>2015-09-14 17:39:09 +0200
commit4fa7e95e7f56f0c27b944e8f3b649b98dfaf87eb (patch)
treee9b96f944e29cbba30fc0d68f07bb1cef8ae8eee /nix-utils.sh
parenta29bcf131cf172d9d52f1e54b2de3c43fb6af587 (diff)
Add: nix-script repl
This is a combination of 23 commits: * Add first draft for nix-shell repl * Remove functions which are in nix-utils.sh * Minify if-then-exit * Remove sudo run... why do I actually have this? * Include helpers * Add help text * Remove old arguments in parsing code * Dont print on stderr, do debugging output here * Remove explain checker, use dbg() as output function * Fix checker * Use bash to print * Use "exit" or "quit" to exit nix-repl * Remove doubled caller code * Move: script_for() function to helpers * Remove old variables * Fix bash call * move all_commands() function to nix-utils.sh * Formatted and extended all_commands() function * Lists executables only. * Shorten error message * Add helper to check whether a string contains a string * Add possibility to execute simple bash commands in repl * The more debug output, the better * More things, we should really squash this stuff
Diffstat (limited to 'nix-utils.sh')
-rw-r--r--nix-utils.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/nix-utils.sh b/nix-utils.sh
index 9e2fd3c..a34a2ee 100644
--- a/nix-utils.sh
+++ b/nix-utils.sh
@@ -6,6 +6,13 @@ Yellow='\e[0;33m'
Green='\e[0;32m'
#
+# Check whether a string (2nd arg) contains a substring (1st arg)
+#
+stringcontains() {
+ [ -z "${2##*$1*}" ]
+}
+
+#
# Print on stderr, in red
#
stderr() {
@@ -28,6 +35,25 @@ stdout() {
}
#
+# List all available commands as script path
+#
+all_commands() {
+ find $(dirname ${BASH_SOURCE[0]}) \
+ -type f \
+ -executable \
+ -name "nix-script-*.sh"
+}
+
+#
+# Get the name of the script file for the command passed as argument
+#
+# Does not check whether the file exists.
+#
+script_for() {
+ echo "$(dirname ${BASH_SOURCE[0]})/nix-script-${1}.sh"
+}
+
+#
# Get the command name from a script path
#
scriptname_to_command() {