when built with _FORTIFY_SOURCE it will check whether the buffer
has as much space as the argument passed to snprintf:
7b544224f8/debug/snprintf_chk.c (L28-L29)
this results in some false positives when the snprintf provided
len argument is bigger than the buffer size (but the result
would have fit into the buffer anyways).
fix this by passing the proper size to snprintf as argument.
(the +1 len isn't necessary, but add it just in case.)
Fixes: https://github.com/jarun/nnn/issues/1931
On OpenBSD at least one of O_RDONLY, O_WRONLY or O_RDWR is needed to open a file.
In creating a new file none of those is set, which leads to an EINVAL error ("invalid argument").
Since the new file is only created and never read, I chose to use O_WRONLY.
This moves setting PWD environment variable closer to the places where child process (that needs PWD correctly set) is started instead of start it on browse.
This is to cd to path as it pointed by symlink, not to it's real path. Bookmarked directory may itself contain symlinks in path, which should be respected.
For example: if directory is physically in /mnt/storage/some and it's symlinked to ~/some and directory ~/some/dir added to bookmarks, it's expected that when following bookmark directory will be changed to ~/some/dir (as in bookmark's link) not to /mnt/storage/some/dir (as dir real path).
If `path` is not provided to `abspath`, later will do `getcwd`, and it's result will differ from `path`. This causes problem that when creating directory inside path reached with symlink, subsequent call to get_cwd_entry does not recognize newly created path as subpath of current path, thus not selecting newly created element.
the size of g_buf depends on PATH_MAX and NAME_MAX which on certain
platforms (such as mac) might not be big enough to decode the help
string. use an explicit buffer with proper size instead.
Closes: https://github.com/jarun/nnn/issues/1768
This is useful for situations where the executable is compiled with
readline support but the user wants to use the native prompt. Often
this happens because packagers build without readline disabled.