What was recommended is to use PATH variable (as you suggest) and then fall back to the code I gave.
On Wed, Jul 2, 2014 at 11:00 AM, Elias Mårtenson <[email protected]> wrote: > Neat, although I believe directly looking at the PATH variable is more > portable. It works on all Unices as well as Windows. > > Regards, > Elias > > > On 2 July 2014 23:54, Blake McBride <[email protected]> wrote: > >> I found this for Unix/Linux systems: >> >> >> #include <unistd.h>#include <sys/types.h>#include <pwd.h> >> struct passwd *pw = getpwuid(getuid()); >> const char *homedir = pw->pw_dir; >> >> >> >> >> On Wed, Jul 2, 2014 at 10:44 AM, Elias Mårtenson <[email protected]> >> wrote: >> >>> I have to agree with Blake here. Ideally there should be a call to >>> getenv("HOME") and if that returns non-NULL, then use the .apl_history >>> in $HOME/.apl/apl_history or something like that. >>> >>> If it returns NULL, well, then fall back to current directory I suppose. >>> >>> I could make the Emacs mode use the same file, so that th ehistory is >>> shared between emacs and non-emacs sessions. >>> >>> Regards, >>> Elias >>> >>> >>> On 2 July 2014 23:41, Blake McBride <[email protected]> wrote: >>> >>>> Dear Juergen, >>>> >>>> If you have trouble reliably finding the home directory, how do you >>>> find the preferences file? >>>> >>>> I would say to find the .apl.history file in the same way and place you >>>> find the .gnu-apl directory. That would be consistent. >>>> >>>> The problem I am having is that since I use GNU APL from the command >>>> line, every time I start GNU APL up, I first have to check the directory I >>>> am in, otherwise I get a bunch of random .apl.history files all over the >>>> place. >>>> >>>> I understand that I can fix the problem in my preferences file, but now >>>> I have to remember to potentially edit that file for each user or machine I >>>> am on to account for the different home directory. I don't have to do that >>>> with my .gnu-emacs file. >>>> >>>> Either way is fine. Just sharing my opinion. >>>> >>>> Thanks! >>>> >>>> Blake >>>> >>>> >>>> >>>> On Wed, Jul 2, 2014 at 9:52 AM, Juergen Sauermann < >>>> [email protected]> wrote: >>>> >>>>> Hi Blake, >>>>> >>>>> yes. The problem with that is that it requires the presence of a home >>>>> directory. >>>>> >>>>> There are use cases like scripting where the interpreter cannot figure >>>>> where the >>>>> home directory is located and my strategy is to depend on as few >>>>> environment >>>>> variables (like $HOME or $PWD) as possible. >>>>> >>>>> Note that ~ is a shell convention and not a file system property so >>>>> that ~/.apl.history >>>>> or $HOME/.apl.history may fail under certain circumstances. >>>>> >>>>> /// Jürgen >>>>> >>>>> >>>>> >>>>> On 07/02/2014 04:25 PM, Blake McBride wrote: >>>>> >>>>> Dear Juergen, >>>>> >>>>> Thanks. I can do that, but every other Linux program I have ever >>>>> used, although it may allow me to specify a config file location as you >>>>> do, >>>>> the default is always in the home directory. >>>>> >>>>> Thanks. >>>>> >>>>> Blake >>>>> >>>>> >>>>> >>>>> On Wed, Jul 2, 2014 at 6:24 AM, Juergen Sauermann < >>>>> [email protected]> wrote: >>>>> >>>>>> Hi Blake, >>>>>> >>>>>> you can set the path in the preferences files: >>>>>> >>>>>> READLINE_HISTORY_PATH = /home/... >>>>>> >>>>>> /// Jürgen >>>>>> >>>>>> >>>>>> >>>>>> On 07/01/2014 11:14 PM, Blake McBride wrote: >>>>>> >>>>>>> GNU APL creates a .apl.history in whatever directory APL is started >>>>>>> up in. This is unlike all other system I've seen, and a problem when >>>>>>> you >>>>>>> don't start APL in the same directory each time. I think rather than >>>>>>> .apl.history, the system should use ~/.apl.history >>>>>>> In other words keep in the home directory. >>>>>>> >>>>>>> Thanks. >>>>>>> >>>>>>> Blake >>>>>>> >>>>>>> >>>>>> >>>>> >>>>> >>>> >>> >> >
