/useful/trunk-1

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/useful/trunk-1

« back to all changes in this revision

Viewing changes to scripts/useful.inc.sh

  • Committer: Gustav Hartvigsson
  • Date: 2022-03-22 16:38:04 UTC
  • Revision ID: git-v1:5f6cfed1c6fef9c23b0efd88abd3bea1f3a04e4b
* Make gifs work.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env bash
2
 
 
3
 
####
4
 
# FILE NAME useful.inc.sh
5
 
6
 
# PURPOSE
7
 
#   This file provides usefule bash libary functions.
8
 
####
9
 
# Add the following to your script to be able to include it:
10
 
#     __SCRIPT_ROOT=$(dirname $(readlink -f $0))
11
 
#     source $__SCRIPT_ROOT/useful.inc.sh
12
 
####
13
 
 
14
 
####
15
 
# FUNCTION __silent
16
 
#
17
 
# PURPOSE
18
 
#   Silent a run command.
19
 
#
20
 
# ARGUMENTS
21
 
#   A command and it's arguments.
22
 
#
23
 
# RETURNS
24
 
#   Exit code of command.
25
 
#
26
 
####
27
 
function __silent () {
28
 
  $@ >> /dev/null 2>&1
29
 
  return $?
30
 
}
31
 
 
32
 
####
33
 
# FUNCTION __find_tool
34
 
#
35
 
# PURPOSE
36
 
#   checks if a tool (progam) exists.
37
 
#
38
 
# NOTE
39
 
#   You need to specify "__SANITY=true" among your globals.
40
 
####
41
 
function __find_tool () {
42
 
  __silent which $1
43
 
 
44
 
  if [[ $? > 0 ]]; then
45
 
    echo "    Can't find tool \"${1}\"."
46
 
    __SANITY=false
47
 
  fi
48
 
}