tilde-expansion

How do I find a user's home directory in Perl?

I need to check whether a file in a user's home directory exists so use file check: if ( -e "~/foo.txt" ) { print "yes, it exists!" ; } Even though there is a file called foo.txt under the user's home directory, Perl always complains that there is no such file or directory. When I replace "~" with /home/jimmy (let's say the user is...

Tilde-based Paths in Objective-C

In Objective-C, how do I go about converting tilde-based pathnames to full pathnames? That is, I'd like to convert from ~/sandbox to /Users/TheBobs/sandbox. ...

have to determine all users home directories - tilde scripting problem

Assume someuser has a home directory /home/someuser NAME=someuser In bash - what expression to I use combining tilde (~) and $NAME to return the users home directory? HOMEDIRECTORY=~someuser echo $HOMEDIRECTORY /home/someuser NAME=someuser echo ~$NAME ~someuser any suggestions? ...

Environment variable expansion for C++

I need to get a %TEMP% environmental variable value string in Windows platform. If I try to use any methods(C / C++) (getenv (), …) to get this environmental variable, it returns with “~” in that string. For Example: C:\DOCUME~1\pkp\LOCALS~1\Temp. But I need to get full string for some reasons, as below: C:\Documents and Settings\p...

Why can't QFile read from the "~" directory?

I've tried the following short example to find out about a bug in a bigger program I am working on. It looks like QFile doesn't support unix (or the shell's) notation for the home directory: #include <QFile> #include <QDebug> int main() { QFile f("~/.vimrc"); if (f.open(QIODevice::ReadOnly)) { qD...

How to manually expand a special variable (ex: ~ tilde) in bash

I have a variable in my bash script whose value is something like this: ~/a/b/c Note that it is unexpanded tilde. When I do ls -lt on this variable (call it $VAR), I get no such directory. I want to let bash interpret/expand this variable without executing it. In other words, I want bash to run eval but not run the evaluated command. ...