Advertisement
iGluko

Untitled

Jun 22nd, 2021
959
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.56 KB | None | 0 0
  1. #!/bin/bash
  2. # exit when any command fails
  3. set -e
  4.  
  5. error() {
  6.     unset FUNCNAME[0] #remove this function name from callstack list
  7.     echo "ERROR callstack(${FUNCNAME[@]}): $*" 1>&2
  8.     exit 1
  9. }
  10.  
  11. read_file() {
  12.         #---check input parameters---#
  13.         local path=$1
  14.         #---read file to output varible---#
  15.         local output="$(cat $path 2>&1)" status="$?"
  16.         if [[ $status -ne 0 ]]; then
  17.         error $output
  18.                 exit
  19.     fi
  20.     echo "$output"
  21. }
  22.  
  23. test() {
  24.    local io=$(read_file "/root/pve-zfs-clone/tests/test_file_1")
  25. }
  26. test
  27. echo 567
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement