ignore newlines.

This commit is contained in:
Christopher Jeffrey 2014-08-05 18:56:39 -07:00
parent 9fd0ec8074
commit 80bd1e8cf0
2 changed files with 12 additions and 4 deletions

14
slock.c
View File

@ -318,9 +318,17 @@ main(int argc, char **argv) {
Display *dpy;
int screen;
if((argc >= 2) && !strcmp("-p", argv[1]))
g_pw = argv[2];
else if((argc >= 2) && !strcmp("-v", argv[1]))
if((argc >= 2) && !strcmp("-p", argv[1])) {
g_pw = strdup(argv[2]);
int i = 0;
while (g_pw[i]) {
if (g_pw[i] == '\r' || g_pw[i] == '\n') {
g_pw[i] = '\0';
break;
}
i++;
}
} else if((argc >= 2) && !strcmp("-v", argv[1]))
die("slock-%s, © 2006-2012 Anselm R Garbe\n", VERSION);
else if(argc != 1)
usage();

View File

@ -16,6 +16,6 @@ fi
exec 2> /dev/null
pw=$1
if test -z "$pw"; then
pw=$(cat ~/.slock_passwd | xargs printf '%s')
pw=$(cat ~/.slock_passwd)
fi
exec slock -p "$pw"