Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/sesh.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ main(int argc, char *argv[], char *envp[])
unsigned int flags = CD_SUDOEDIT_FOLLOW;
char *edit_user = NULL;
int ch, ret, fd = -1;
bool login_shell;
debug_decl(main, SUDO_DEBUG_MAIN);

initprogname(argc > 0 ? argv[0] : "sesh");
Expand All @@ -101,6 +102,9 @@ main(int argc, char *argv[], char *envp[])
bindtextdomain(PACKAGE_NAME, LOCALEDIR);
textdomain(PACKAGE_NAME);

/* If the first char of argv[0] is '-', we are running a login shell. */
login_shell = argv[0] != NULL && argv[0][0] == '-';

while ((ch = getopt_long(argc, argv, short_opts, long_opts, NULL)) != -1) {
switch (ch) {
case 'c':
Expand Down Expand Up @@ -172,7 +176,6 @@ main(int argc, char *argv[], char *envp[])
}
ret = sesh_sudoedit(mode, flags, edit_user, argc, argv);
} else {
bool login_shell;
char *cmnd;

if (!ISSET(flags, CD_SUDOEDIT_FOLLOW)) {
Expand All @@ -186,9 +189,6 @@ main(int argc, char *argv[], char *envp[])
usage();
}

/* If the first char of argv[0] is '-', we are running a login shell. */
login_shell = argv[0][0] == '-';

/* We must change the directory in sesh after the context changes. */
if (rundir != NULL && chdir(rundir) == -1) {
sudo_warnx(U_("unable to change directory to %s"), rundir);
Expand Down