Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

hey all i am attempting my first bash script. so i would like to prompt the user to find out where they would like a cloned repo to be saved

currently i am assigning it like this

warpToLocation="${HOME}/apps/"

is there some way to do it like this

read -e -p "Enter the path to the file: " -i "${HOME}/apps/" FILEPATH

but save the result as warpToLocation

sorry if this is a noobish question its brand new to me

EDIT:

#!/bin/bash

echo "where would you like to install your repos?"

read -p "Enter the path to the file: " temp
warpToLocation="${HOME}/$temp/"

warpInLocations=("git@github.com:cca/toolkit.git" "git@github.com:cca/sms.git" "git@github.com:cca/boogle.git" "git@github.com:cca/cairo.git")



echo "warping in toolkit, sms, boogle and cairo"
for repo in "${warpInLocations[@]}"
do
  warpInDir=$repo
  warpInDir=${warpInDir#*/}
  warpInDir=${warpInDir%.*}
  if [ -d "$warpToLocation"]; then
    echo "somethings in the way.. $warpInDir all ready exists"
  else
    git clone $repo $warpInDir
fi

done

what i had done to get that error was add the code you gave me.

the issue with that is that -e(which allows you to edit the input with arrows) and -i(a preview/optional answer) runs on bash version 4 and higher and i am running version GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12).

so remove it. sorry i wasted all your time those who came to help me.

i should have done some homework before coming to you.

share|improve this question

1 Answer 1

What's wrong with

read -e -p "Enter the path to the file: " -i "${HOME}/apps/" warpToLocation

?

share|improve this answer
    
so FILEPATH is a variable. i thought it was a standard.. thanks man sorry its my first time dipping into bash i am scared i destroy my os –  TheLegend May 24 '13 at 14:51
    
invalid option read: usage: read [-ers] [-u fd] [-t timeout] [-p prompt] [-a array] [-n nchars] [-d delim] [name ...] warping in toolkit, sms, boogle and cairo –  TheLegend May 24 '13 at 14:53
    
I have no idea what you typed in your program, but I'm pretty sure that the command I told you works in bash. If you type something else and get error messages, it's fairly pointless to copy only the error message and hope that others can reconstruct your problem from that. –  Uwe May 24 '13 at 15:05
    
that would be the result that bash gave me when i tried read -e -p "Enter the path to the file: " -i "${HOME}/apps/" warpToLocation –  TheLegend May 24 '13 at 15:26
    
Your read doesn't have a -i option? Are you really using bash? Which version? bash --version –  Uwe May 24 '13 at 15:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.