Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » POSIX home directory symbol '~' is causing trouble
POSIX home directory symbol '~' is causing trouble [message #57620] Mon, 11 October 2021 00:13 Go to next message
Lance is currently offline  Lance
Messages: 381
Registered: March 2007
Senior Member
#include <Core/Core.h>

using namespace Upp;

CONSOLE_APP_MAIN
{
	
	FileOut fo("~/abc.txt");
	fo<<"U++ rocks!";
}


The above code won't work on Ubuntu. No expection thrown either. It just quietly does nothging. But when I replace ~ with something like /home/user1, it works just fine.

I also notice this home directory symbol causing trouble in similar situation: I use it in LocalProcess and pass it a command that is known to not run, hence a exit code 1 is expected to be returned by the OS. Yet when I use ~ to denote home directory, the LocalProcess always return 0 exit code.

Is ~ a bash thing(means bash or similar shells interpret it to produce a conforming path) so that we really should not use it on U++?
Re: POSIX home directory symbol '~' is causing trouble [message #57621 is a reply to message #57620] Mon, 11 October 2021 02:00 Go to previous messageGo to next message
Lance is currently offline  Lance
Messages: 381
Registered: March 2007
Senior Member
I try it with std::fstream, it fails too. Some research shows that replacing ~ with $HOME is a shell feature. So there is nothing U++ needs to do. The problem is closed.
Re: POSIX home directory symbol '~' is causing trouble [message #57622 is a reply to message #57621] Mon, 11 October 2021 04:49 Go to previous messageGo to next message
jjacksonRIAB is currently offline  jjacksonRIAB
Messages: 105
Registered: June 2011
Experienced Member
Incidentally if you need the home directory you can just call GetHomeDirectory();
Re: POSIX home directory symbol '~' is causing trouble [message #57623 is a reply to message #57622] Mon, 11 October 2021 05:16 Go to previous message
Lance is currently offline  Lance
Messages: 381
Registered: March 2007
Senior Member
Thank you, jjacksonRIAB!
Previous Topic: Strings with national specific characters are wrongly sorted - Sort
Next Topic: Magic enum
Goto Forum:
  


Current Time: Fri Dec 03 13:26:37 CET 2021

Total time taken to generate the page: 0.01039 seconds