Project

General

Profile

Download (656 Bytes) Statistics
| Branch: | Tag: | Revision:

haketilo / shell_utils.sh @ d7e48c58

1
# Copyright (C) 2021 Wojtek Kosior
2
# Redistribution terms are gathered in the `copyright' file.
3

    
4
# This file is meant to be sourced in sh.
5

    
6
ENDL="
7
"
8

    
9
# A "raw" echo, interprets neither backclash escapes nor command-line options.
10
# Does not emit trailing newline.
11
ech() {
12
    printf %s "$*"
13
}
14

    
15
errcho() {
16
    echo "$@" >&2
17
}
18

    
19
map_set_instr() {
20
    echo "$1__$2='$3'"
21
}
22

    
23
map_set() {
24
    eval "$(map_set_instr "$@")"
25
}
26

    
27
map_set_export() {
28
    eval "export $(map_set_instr "$@")"
29
}
30

    
31
map_get() {
32
    eval "echo \"\$$1__$2\""
33
}
34

    
35
map_del_instr() {
36
    echo "unset $1__$2"
37
}
38

    
39
map_del() {
40
    eval "$(map_del_instr "$@")"
41
}
42

    
43
sanitize() {
44
    echo "$1" | tr /.- _
45
}
(8-8/9)