linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kay Sievers <kay.sievers@vrfy.org>
To: linux-hotplug@vger.kernel.org
Subject: Re: [udev] remove '\n' from end of callout return
Date: Mon, 15 Dec 2003 02:48:04 +0000	[thread overview]
Message-ID: <marc-linux-hotplug-107145663219456@msgid-missing> (raw)

[-- Attachment #1: Type: text/plain, Size: 707 bytes --]

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=

[-- Attachment #2: 03-remove-newline-from-callout-return.diff --]
[-- Type: text/plain, Size: 942 bytes --]

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) {

             reply	other threads:[~2003-12-15  2:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-15  2:48 Kay Sievers [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-12-15 22:38 [udev] remove '\n' from end of callout return Greg KH
2003-12-15  2:27 Kay Sievers
2003-12-15  1:26 Kay Sievers
2003-12-15  1:32 ` Kay Sievers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=marc-linux-hotplug-107145663219456@msgid-missing \
    --to=kay.sievers@vrfy.org \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).