diff --git a/TODO b/TODO index 325f2c3..6e8a543 100644 --- a/TODO +++ b/TODO @@ -55,6 +55,10 @@ done to provide a consistent way of passing multiple host files on the commandline. + - .include targets (file name specifications) may now reference + previously-define variables. + + [BUG FIXES] - File transfers now properly honor the -s (silent output) flag. @@ -67,8 +71,6 @@ - Protect path walk from files/dirs that cannot be opened. - - File Xfer: Allow from within cmd files. - Future ------ diff --git a/tsshbatch.py b/tsshbatch.py index f2ed081..d538223 100755 --- a/tsshbatch.py +++ b/tsshbatch.py @@ -700,7 +700,7 @@ # Process file includes elif line: if line.startswith(INCLUDE): - fname = ConditionLine(line.split(INCLUDE)[1]) + fname = VarSub(ConditionLine(line.split(INCLUDE)[1])) ReadFile(fname, envvar, listcontainer, containingfile=filename) # It's a normal line - do variable substitution and save diff --git a/tsshbatch.rst b/tsshbatch.rst index 640446f..94c47c8 100644 --- a/tsshbatch.rst +++ b/tsshbatch.rst @@ -701,6 +701,28 @@ the same file multiple times, either in a single file or throughout other included files, so long as no circular include is created. +The target of a ``.include`` directive can also contain variable +references. Note, however, that references to builtin variables will +fail unless you have overriden them. Why? Because builtins don't get +defined until a host connection is attempted. This doesn't happen +until *after* all variable processing and file includes have been +done. So:: + + .define MYINCLUDE = /some/fine/file # OK + .include MYINCLUDE + + .define MYINCLUDE = ! find /some/path -name includeski # OK + .include MYINCLUDE + + .include __HOSTNAME__ # Nope, not defined yet - + # tries to include file called '__HOSTNAME__' + + .define __HOSTNAME__ ! hostname # Override the builtin + .include __HOSTNAME__ # OK + +As a matter of keeping things simple, stick to User Defined variables +as part of an ``.include`` target. + Search Paths ============