Advertisement
tolikpunkoff

askstring

May 10th, 2019
797
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.29 KB | None | 0 0
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement