Re: scripts one after the other

2016-03-29 Thread Quinn Fissler
On 26 March 2016 at 01:28, Val Krem  wrote:
>
> is it possible to combine the two scripts in one so that I can define the 
> varietals at one spot.  It would be less prone to error.


Yes - you can have a script with a "case" and hard link to another
name (you can symlink but they're not as efficient as hard links)


#!/bin/bash

# set your variables here.
F=foo
B=bar

case "$0" in
   "*1.sh")
  check your parameters for the first script...
  do stuff to create output | your_script_2.sh
   ;;
   "*2.sh")
  # some prog which reads input or read the input in bash
  while read Col1 Col2 Col3 RestOfLine
  do
 do your stuff - reading a line at a time lets you pick off
columns if needed...
  done
   ;;
   "*[!12].sh")
  echo We do not expect to be called $0
  exit
   ;;
esac



Parse error with consecutive case statements inside $()

2016-03-29 Thread Christian Franke

Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: cygwin
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash.exe' -DCONF_HOSTTYPE='i686' 
-DCONF_OSTYPE='cygwin' -DCONF_MACHTYPE='i686-pc-cygwin' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' 
-DSHELL -DHAVE_CONFIG_H -DRECYCLES_PIDS   -I. 
-I/usr/src/bash-4.3.42-4.i686/src/bash-4.3 
-I/usr/src/bash-4.3.42-4.i686/src/bash-4.3/include 
-I/usr/src/bash-4.3.42-4.i686/src/bash-4.3/lib  -DWORDEXP_OPTION -ggdb 
-O2 -pipe -Wimplicit-function-declaration 
-fdebug-prefix-map=/usr/src/bash-4.3.42-4.i686/build=/usr/src/debug/bash-4.3.42-4 
-fdebug-prefix-map=/usr/src/bash-4.3.42-4.i686/src/bash-4.3=/usr/src/debug/bash-4.3.42-4
uname output: CYGWIN_NT-6.1-WOW Alien2 2.4.1(0.293/5/3) 2016-01-24 11:24 
i686 Cygwin

Machine Type: i686-pc-cygwin

Bash Version: 4.3
Patch Level: 42
Release Status: release

Description:
If consecutive case statements are inside of $(...), the parser 
misinterprets first ')' from second case statement as the end of command 
substitution.


The possibly related patch bash43-042 is already included in this version.


Repeat-By:

$ cat bug.sh
x=$(
  case 1 in
1) echo 1
  esac
  case 2 in
2) echo 2
  esac
)
echo "$x"


$ bash -xv bug.sh
x=$(
  case 1 in
1) echo 1
  esac
  case 2 in
2) echo 2
bug.sh: command substitution: line 13: syntax error: unexpected end of file
bug.sh: line 7: syntax error near unexpected token `esac'
bug.sh: line 7: ` esac'


$ dash bug.sh
1
2


Workarounds:
- append semicolon behind first 'esac', or
- insert any command line between the case statements, or
- use `...` instead of $(...)


--
Christian Franke