Skip to contentSkip to conversation

remove '\n' from end of callout return

udev Kay Sievers 1 participant 2 messages Dec 15, 2003

lore
Share & tools
lore
#0 lore raw

Attched 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" is a callout script.

thanks,
Kay

-------------------------------------------------------
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_id78&alloc_id371&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#1 lore raw

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=

namedev.c +4 -0
diff -Nru a/namedev.c b/namedev.c
@@ -266,6 +266,7 @@
 	char buffer[256];
 	char *arg;
 	char *args[CALLOUT_MAXARG];
+	char *pos;
 	int i;
 
 	dbg("callout to '%s'", dev->exec_program);
@@ -326,6 +327,9 @@
 				strncpy(value, buffer, len);
 			}
 		}
+		pos = value + strlen(value)-1;
+		if (pos[0] == '\n')
+			pos[0] = '\0';
 		dbg("callout returned '%s'", value);
 		close(fds[0]);
 		res = wait(&status);