about summary refs log tree commit diff
path: root/.js_to_bash.sh
blob: 22a70a556077208c4d8bae815116dfae77d7c91e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# js function syntax for bash

function trimend {
    LENGTH=${#1}
    AMT=$2
    TAKE=$((LENGTH-AMT))
    echo $1 | cut "-c-$TAKE"
}

function trimfront {
    TMP0=$(echo $1 | rev)
    TMP1=$(trimend $TMP0 $2 | rev)
    echo $TMP1
}

function length {
    echo ${#1}
}

function slice {
  start="$1"
  end="$2"
  string="$3"
  echo "${string:${start}:${end}}"
}

function setInterval {
  eval "while true; do $1; sleep $2; done"
}