30 |
30 |
31 #include "talon_process.h" |
31 #include "talon_process.h" |
32 #include "sema.h" |
32 #include "sema.h" |
33 #include "buffer.h" |
33 #include "buffer.h" |
34 #include "../config.h" |
34 #include "../config.h" |
|
35 |
|
36 #ifdef HAS_GETCOMMANDLINE |
|
37 #include "chomp.h" |
|
38 #endif |
35 |
39 |
36 /* The output semaphore. */ |
40 /* The output semaphore. */ |
37 sbs_semaphore talon_sem; |
41 sbs_semaphore talon_sem; |
38 |
42 |
39 #define TALON_ATTEMPT_STRMAX 32 |
43 #define TALON_ATTEMPT_STRMAX 32 |
229 char *recipe = NULL; |
233 char *recipe = NULL; |
230 int talon_returncode = 0; |
234 int talon_returncode = 0; |
231 |
235 |
232 #ifdef HAS_GETCOMMANDLINE |
236 #ifdef HAS_GETCOMMANDLINE |
233 char *commandline= GetCommandLine(); |
237 char *commandline= GetCommandLine(); |
234 DEBUG(("talon: commandline: %s\n", commandline)); |
|
235 /* |
238 /* |
236 * The command line should be either, |
239 * The command line should be either, |
237 * talon -c "some shell commands" |
240 * talon -c "some shell commands" |
238 * or |
241 * or |
239 * talon shell_script_file |
242 * talon shell_script_file |
240 * |
243 * |
241 * talon could be an absolute path and may have a .exe extension. |
244 * talon could be an absolute path and may have a .exe extension. |
242 */ |
245 */ |
243 recipe = strstr(commandline, "-c"); |
246 |
|
247 |
|
248 recipe = chompCommand(commandline); |
244 if (recipe) |
249 if (recipe) |
245 { |
250 { |
246 /* there was a -c so extract the quoted commands */ |
251 /* there was a -c so extract the quoted commands */ |
247 |
252 |
248 while (*recipe != '"' && *recipe != '\0') |
|
249 recipe++; |
|
250 |
|
251 if (*recipe != '"') /* we found -c but no following quote */ |
|
252 { |
|
253 error("talon: error: unquoted recipe in shell call '%s'\n", commandline); |
|
254 return 1; |
|
255 } |
|
256 recipe++; |
|
257 |
|
258 int recipelen = strlen(recipe); |
253 int recipelen = strlen(recipe); |
259 if (recipelen > 0 && recipe[recipelen - 1] == '"') |
254 if (recipelen > 0 && recipe[recipelen - 1] == '"') |
260 recipe[recipelen - 1] = '\0'; /* remove trailing quote */ |
255 recipe[recipelen - 1] = '\0'; /* remove trailing quote */ |
261 } |
256 } |
262 else |
257 else |