views:

50

answers:

4

The keytool does not resolve impartial directories. Ie this works:

keytool -keystore "/users/me/Desktop" ...

This doesn't:

keytool -keystore "~/Desktop" ...

Is there something that I could call like this:

keytool -keystore "$(<cmd> ~/Desktop)" ...

Update

I guess I should actually be more specific:

This is really what I am doing:

myVar=~/Desktop
<allow user to overwrite default value of myVar>
keytool -keystore "$myVar" ...

I don't think that it is safe to have $myVar unquoted in the keytool command in case someone puts some malicious code in there.

+2  A: 

I don't think this is a programming question, but did you try it without the quotes? i.e.

keytool -keystore ~/Desktop ...
Gabe
+4  A: 

That's because you are quoting the path. Keytool, or any other command line program in unix is agnostic of the wildrcards, because the shell is used to actually expanding the path names. If you don't quote the path, it'll work peachy.

Will Hartung
I don't know anything about keytool, but i'd say that is not necessarily true based on the existence of $@.
frankc
Double quotes should be fine. Single quotes will treat it as a literal string.
DevNull
+1  A: 

eval echo "~/foo"

e.g. keytool -keystore $(eval echo ~/Desktop)

frankc
This is not working `CLIENT_PATH="`eval echo ~/Desktop`"`
sixtyfootersdude
works for me. Are you sure you don't have your close quotes reverse as you do in what you put in the comment?
frankc
A: 

How about

keytool -keystore "$(echo ~/Desktop)"

or

keytool -keystore "$HOME/Desktop"

But, on the other hand, ~/Desktop should work fine as well. Tried with bash only, don't have any other Bourne shells here.

mihi
The first one doesn't work. The second one does.
sixtyfootersdude