浏览代码

handle cases where HOME is missing

master
Arun Prakash Jana 7 年前
父节点
当前提交
70e5ee80a6
找不到此签名对应的密钥 GPG 密钥 ID: A75979F35C080412
共有 1 个文件被更改,包括 6 次插入3 次删除
  1. +6
    -3
      nnn.c

+ 6
- 3
nnn.c 查看文件

@@ -391,7 +391,7 @@ printerr(int linenum)
{ {
exitcurses(); exitcurses();
fprintf(stderr, "line %d: (%d) %s\n", linenum, errno, strerror(errno)); fprintf(stderr, "line %d: (%d) %s\n", linenum, errno, strerror(errno));
if (cfg.noxdisplay)
if (cfg.noxdisplay && g_cppath[0])
unlink(g_cppath); unlink(g_cppath);
exit(1); exit(1);
} }
@@ -608,6 +608,9 @@ xbasename(char *path)
static void static void
writecp(const char *buf, const size_t buflen) writecp(const char *buf, const size_t buflen)
{ {
if (!g_cppath[0])
return;

FILE *fp = fopen(g_cppath, "w"); FILE *fp = fopen(g_cppath, "w");


if (fp) { if (fp) {
@@ -3417,7 +3420,7 @@ main(int argc, char *argv[])
cfg.quote = 1; cfg.quote = 1;


/* Check if X11 is available */ /* Check if X11 is available */
if (getenv("NNN_NO_X")) {
if (getenv("NNN_NO_X") && getenv("HOME")) {
cfg.noxdisplay = 1; cfg.noxdisplay = 1;
size_t len = xstrlcpy(g_cppath, getenv("HOME"), 48); size_t len = xstrlcpy(g_cppath, getenv("HOME"), 48);
xstrlcpy(g_cppath + len - 1, "/.nnncp", 48 - len); xstrlcpy(g_cppath + len - 1, "/.nnncp", 48 - len);
@@ -3442,7 +3445,7 @@ main(int argc, char *argv[])
browse(ipath, ifilter); browse(ipath, ifilter);
exitcurses(); exitcurses();


if (cfg.noxdisplay)
if (cfg.noxdisplay && g_cppath[0])
unlink(g_cppath); unlink(g_cppath);


#ifdef LINUX_INOTIFY #ifdef LINUX_INOTIFY


正在加载...
取消
保存