From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kay Sievers Date: Mon, 15 Dec 2003 02:48:04 +0000 Subject: Re: [udev] remove '\n' from end of callout return MIME-Version: 1 Content-Type: multipart/mixed; boundary="9amGYk9869ThD9tj" Message-Id: List-Id: To: linux-hotplug@vger.kernel.org --9amGYk9869ThD9tj Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sorry, i hit the second time that key in Mutt that sends the mail instead of selecting the file to attach? We have for every line of code one mail now, luckily the patch is so small :) thanks, Kay > Yes, there are only 3 lines in the patch, but this one is still better :) > > > Uups, new mail. It's better to attach the promised file :) > > > > Attached is a patch to remove a possible newline from the end > > of the callout returned string. So we can use "echo" instead of "echo -n" > > in a callout script, to match with ID= > > > > thanks, > > Kay > > > > > > 03-remove-newline-from-callout-return.diff > > remove possible newline at end of callout output, > > for easier matching with ID= --9amGYk9869ThD9tj Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="03-remove-newline-from-callout-return.diff" diff -Nru a/namedev.c b/namedev.c --- a/namedev.c Mon Dec 15 03:25:29 2003 +++ b/namedev.c Mon Dec 15 03:25:29 2003 @@ -264,7 +264,7 @@ pid_t pid; int value_set = 0; char buffer[256]; - char *arg; + char *pos; char *args[CALLOUT_MAXARG]; int i; @@ -286,9 +286,9 @@ dup(fds[1]); /* dup write side of pipe to STDOUT */ if (strchr(dev->exec_program, ' ')) { /* callout with arguments */ - arg = dev->exec_program; + pos = dev->exec_program; for (i=0; i < CALLOUT_MAXARG-1; i++) { - args[i] = strsep(&arg, " "); + args[i] = strsep(&pos, " "); if (args[i] == NULL) break; } @@ -324,9 +324,12 @@ } else { value_set = 1; strncpy(value, buffer, len); + pos = value + strlen(value)-1; + if (pos[0] == '\n') + pos[0] = '\0'; + dbg("callout returned '%s'", value); } } - dbg("callout returned '%s'", value); close(fds[0]); res = wait(&status); if (res < 0) { --9amGYk9869ThD9tj-- ------------------------------------------------------- This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel