tolikpunkoff

askstring

May 10th, 2019
248
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. ask_string() #1-user ask string, #2-default variant
  4. {
  5.     read -r -p "$1 [$2]:"
  6.    
  7.     if [ -z "$REPLY" ]; then
  8.     if [ -n "$2" ]; then
  9.         STR_RESULT=$2
  10.     fi
  11.     else
  12.     STR_RESULT=$REPLY
  13.     fi
  14. }
  15.  
  16. ask_string "Select path" "/home/smallwolfie/test/testdir"
  17. echo $STR_RESULT
RAW Paste Data