aboutsummaryrefslogtreecommitdiffstats
path: root/ves-show.sh
blob: b50487a7c30f53aed77fed071668e408badd0397 (plain)
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
#!/bin/sh
#
# Print the variables stored in an sh-ves environment, one VAR=value per
# line. With no argument, shows the currently active environment.
#
ves_show() {
    env=""
    if [ "$#" -ge 1 ]; then
        env="$1"
    fi

    if ! env=$(_shves_resolve_env "$env"); then
        return 1
    fi

    while IFS= read -r line; do
        case $line in
            export_var:*)
                printf "%s\n" "${line#export_var:}"
                ;;
        esac
    done < "$SHVES_ENV_DIR/$env"

    return 0
}