From 10857629e1fab15f30a7d01ca268e52fd7c96abc Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Sun, 22 Oct 2023 22:16:17 +0200 Subject: [PATCH] add option --pipe (alias for -r / ----no_readline) --- doc/xschem_man/run_xschem.html | 23 ++++++++++++----------- src/main.c | 2 +- src/options.c | 3 +++ src/xschem.help | 6 +++--- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/doc/xschem_man/run_xschem.html b/doc/xschem_man/run_xschem.html index 9d5ae7fb..f329071d 100644 --- a/doc/xschem_man/run_xschem.html +++ b/doc/xschem_man/run_xschem.html @@ -44,6 +44,7 @@ user:~$ xschem .../xschem_library/examples/0_examples_top.sch xschem accepts short (-h) or long (--help) options:

+
 usage: xschem [options] [schematic | symbol ]
 Options:
   -h  --help           Print this help.
@@ -51,23 +52,23 @@ Options:
   -n  --netlist        Do a netlist of the given schematic cell.
   -v  --version        Print version information and exit.
   -V  --vhdl           Set netlist type to VHDL.
-  -S  --simulate       Run a simulation of the current schematc file
-                       (spice/Verilog/VHDL, depending on the netlist
+  -S  --simulate       Run a simulation of the current schematc file 
+                       (spice/Verilog/VHDL, depending on the netlist 
                        type chosen).
   -w  --verilog        Set netlist type to Verilog.
+  --tcl <tcl_cmd>      Execute specified tcl instructions before any other action,
+                       after sourcing xschemrc, this can be used to change xschemrc variables.
   --preinit <tcl_cmd>  Execute specified tcl instructions before any other action,
                        and before loading xschemrc.
-  --tcl <tcl_script>   Execute specified tcl instructions before any other action,
-                       this can be used to change xschemrc variables.
+  --script <file>      Execute specified tcl file as a command script (perhaps with xschem  commands).
   --command <tcl_cmd>  Execute specified tcl commands after completing startup.
   --diff <file>        Show differences with given file.
-  --script <file>      Execute specified tcl file as a command script (perhaps with xschem  commands).
   --tcp_port <number>  Listen to specified tcp port for client connections. (number >=1024).
   -i  --no_rcload      Do not load any xschemrc file.
-  -o <file>            Set output path for netlist.
-  --netlist_path <file>
+  --netlist_path <path>
+  -o <path>            Set output path for netlist.
+  --netlist_filename <file>    
   -N <file>            Set name (only name, not path) of top level netlist file.
-  --netlist_filename <file>
   -t  --tedax          Set netlist type to tEDAx.
   -s  --spice          Set netlist type to SPICE.
   -y  --symbol         Set netlist type to SYMBOL (used when drawing symbols)
@@ -75,9 +76,9 @@ Options:
   -z  --rainbow        Use a raibow-looking layer color table.
   -W  --waves          Show simulation waveforms.
   -f  --flat_netlist   Set flat netlist (for spice format only).
-  -r  --no_readline    Start without the tclreadline package ( this is
-                       necessary if stdin and stdout are to be redirected
-                       for example to /dev/null).
+  -r  --no_readline    Start without the tclreadline package, this is necessary
+      --pipe           if stdin and stdout are to be redirected. This also prevents xschem
+                       from closing stdin / stdout / stderr even if invoked from pipes.
   -c  --color_ps       Set color postscript.
   --plotfile <file>    Use <file> as output for plot (png, svg, ps).
   --rcfile <file>      Use <file> as a rc file for startup instead of the
diff --git a/src/main.c b/src/main.c
index 1db8056e..02debf80 100644
--- a/src/main.c
+++ b/src/main.c
@@ -97,7 +97,7 @@ int main(int argc, char **argv)
   argc = process_options(argc, argv);
 
   /* if invoked in background detach from console */
-  if(getpgrp() != tcgetpgrp(STDOUT_FILENO)) {
+  if(getpgrp() != tcgetpgrp(STDOUT_FILENO) && !cli_opt_no_readline) {
     cli_opt_detach = 1;
   }
 
diff --git a/src/options.c b/src/options.c
index 3cf9dd0a..45ef2c76 100644
--- a/src/options.c
+++ b/src/options.c
@@ -49,6 +49,9 @@ static void check_opt(char *opt, char *optval, int type)
     } else if( (type == SHORT && *opt == 'r') || (type == LONG && !strcmp("no_readline", opt)) ) {
         cli_opt_no_readline=1;
 
+    } else if( (type == LONG && !strcmp("pipe", opt)) ) {
+        cli_opt_no_readline=1;
+
     } else if( (type == SHORT && *opt == 'p') || (type == LONG && !strcmp("postscript", opt)) ) {
         dbg(1, "process_options(): will print postscript/pdf\n");
         cli_opt_do_print=1;
diff --git a/src/xschem.help b/src/xschem.help
index 26ca1676..8892f777 100644
--- a/src/xschem.help
+++ b/src/xschem.help
@@ -29,9 +29,9 @@ Options:
   -z  --rainbow        Use a raibow-looking layer color table.
   -W  --waves          Show simulation waveforms.
   -f  --flat_netlist   Set flat netlist (for spice format only).
-  -r  --no_readline    Start without the tclreadline package ( this is
-                       necessary if stdin and stdout are to be redirected
-                       for example to /dev/null).
+  -r  --no_readline    Start without the tclreadline package, this is necessary
+      --pipe           if stdin and stdout are to be redirected. This also prevents xschem
+                       from closing stdin / stdout / stderr even if invoked from pipes.
   -c  --color_ps       Set color postscript.
   --plotfile     Use  as output for plot (png, svg, ps).
   --rcfile       Use  as a rc file for startup instead of the