Browse Source

Add support for arguments in __bashum_run_n()

People can now run

    __bashum_run_n 100 echo hello world

and it will print "hello world" 100 times, instead of just running
`echo` 100 times and ignoring the `hello world` part.
Alois Mahdal 5 years ago
parent
commit
d5ce4d0e50
1 changed files with 3 additions and 3 deletions
  1. 3
    3
      dotfiles/bash/main.bashrc

+ 3
- 3
dotfiles/bash/main.bashrc View File

65
 
65
 
66
 __bashum_run_n() {
66
 __bashum_run_n() {
67
     #
67
     #
68
-    # Run $2 in background $1 times
68
+    # Run $2.. in background $1 times
69
     #
69
     #
70
-    local n=${1:-1}
70
+    local n=${1:-1}; shift
71
     while test "$n" -gt 0;
71
     while test "$n" -gt 0;
72
     do
72
     do
73
-        "$2" &
73
+        "$@" &
74
         ((n--))
74
         ((n--))
75
     done
75
     done
76
 }
76
 }