[issue15874] argparse cannot parse bash variable arguments in file-given arguments

2012-09-06 Thread Nat Hillard

New submission from Nat Hillard:

When using the argparse argument fromfile_prefix_chars to obtain command line 
arguments from a file, it is not possible to make use of bash environment 
variables within this file. 

Ideally one would be able to `export BAR='/Users/x/Desktop/bar'`, and then give 
arguments such as:

--foo
$BAR

and have this correctly expanded at read time to --foo '/Users/x/Desktop/bar'.

To my knowledge, this is currently only possible if you give the arguments 
directly via the command line:
python test.py --foo $BAR

It would be great to be able to use environment variables within files as well!

--
components: Library (Lib)
messages: 169958
nosy: ZhuangZi, bethard
priority: normal
severity: normal
status: open
title: argparse cannot parse bash variable arguments in file-given arguments
type: behavior
versions: Python 2.7

___
Python tracker 
<http://bugs.python.org/issue15874>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15874] argparse cannot parse shell variable arguments in file-given arguments

2012-09-06 Thread Nat Hillard

Nat Hillard added the comment:

Indeed these are all valid points, and as a zsh user myself I certainly 
considered the alternative shell issue. That said, if it were at all possible, 
through a combination of os.environ / shlex, subprocess, and even `source` if 
necessary, to offload this interpretation to the user's shell (pass the shell a 
given string, receive its interpretation first before further processing), I 
could see a lot of benefit from this. 

Relatedly, I have seem similar requests for environment variable support in 
configparser, here: 
http://grokbase.com/t/python/python-list/03ckhw75xr/parsing-environment-variables-in-configparser-files

This particular proposal is interesting in that it creates an intermediary 
between the file's environment variable syntax and the shell's own. Presumably 
if you standardized the presentation of environment variables within this file 
you could use os.environ once you had recognized it. 

That said, I can understand, however, if this is prohibitively costly to 
implement, and it may well be that this option is ill suited to the task I am 
putting it to.

--
title: argparse cannot parse bash variable arguments in file-given arguments -> 
argparse cannot parse shell variable arguments in file-given arguments

___
Python tracker 
<http://bugs.python.org/issue15874>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15874] argparse cannot parse shell variable arguments in file-given arguments

2012-09-10 Thread Nat Hillard

Nat Hillard added the comment:

Thank you, everyone. Defining a new type for this is just what I needed. No 
additional modifications are necessary on top of this new type.

--
resolution:  -> works for me
status: open -> closed

___
Python tracker 
<http://bugs.python.org/issue15874>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com