Author Topic: autosave path doesn't recognize "~" on Ubuntu  (Read 638 times)

jporkkahtc

  • Senior Community Member
  • Posts: 1663
  • Hero Points: 155
  • Text
autosave path doesn't recognize "~" on Ubuntu
« on: October 06, 2017, 10:29:41 pm »
I set autosave path to ~/.slickedit/autosave

Now slick is creating a folder named  /home/user/src/.../~/autosave deep in my source tree.
Not really what I wanted!

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4485
  • Hero Points: 344
Re: autosave path doesn't recognize "~" on Ubuntu
« Reply #1 on: October 07, 2017, 12:45:59 pm »
Sadly, I don't think this works in a quite a few places (like the options dialog). We tried to put this in only for the most common and important places (like opening a file).

Could be more consistent for sure (we probably need options for this). When this was added, we really weren't sure if it would get us into trouble since Unix allows pretty much any filename character (FYI: SlickEdit does not support putting double quotes in a filename but Unix does).

jporkkahtc

  • Senior Community Member
  • Posts: 1663
  • Hero Points: 155
  • Text
Re: autosave path doesn't recognize "~" on Ubuntu
« Reply #2 on: October 07, 2017, 02:21:43 pm »
I ran into this because I exported all options from my "user1" login and imported them into my "user2" login.
Slick then wanted to autosave into /home/user1/.slickedit/autosave, but failed due to access denied.
So, I change it to be ~/.slickedit/autosave.

What should be used here?

No matter if "~" is recognized or not, Slick should not allow a relative path for somethings, like autosave --- or if relative paths are allowed, it should be relative to the slick config directory - not some random place in the workspace.


Slick "C" needs a pathname type, distinct from _str.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4485
  • Hero Points: 344
Re: autosave path doesn't recognize "~" on Ubuntu
« Reply #3 on: October 08, 2017, 01:38:50 pm »
In this case, we could certainly take advantage of the fact that this can't be a relative path. There's a _isRelative() function for this. Another trick we use on Unix is to check whether the file exists (i.e   file_exists(filename)). If it does, then no translations are performed. Sadly, we can only use a general purpose solution for part of this and the rest requires work for every individual case.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4485
  • Hero Points: 344
Re: autosave path doesn't recognize "~" on Ubuntu
« Reply #4 on: October 08, 2017, 04:00:29 pm »
I've enhanced autosave.e to support environment variables. Use %HOME% instead of ~. I didn't realize that the code we have for expanding ~ is in the function_unix_expansion() which has a bunch of code which really should only be used on Unix and not Windows. This change is a multi-platform change which only supports environment variables when a relative filename is detected. Too bad Windows doesn't set the HOME environment variable like Unix.

Try the attached autosave.e. Tested with RC 4.