Bash – Turning on and off wildcard expansion

I’m dealing with the same problem for a small python script that uses ‘ls’ as sub process.
How to prevent wildcard expansion in bash?

$ set -f
$ /path/to/globme.sh
$ set+f
$ YourFirstArgument YourSecondArgument ...

For detail, follow this link.

It works.

$ set -f
$ python cmdline_args.py 1 2 *
4
['cmdline_args.py', '1', '2', '*']
arguments
1
2
*

Then it creates another problem.


$ ls -l *
ls: cannot access *: No such file or directory
$ ls -l *.py
ls: cannot access *.py: No such file or directory

Back to square one.

About janpenguin

Email: janpenguin [at] riseup [dot] net Every content on the blog is made by Free and Open Source Software in GNU/Linux.
This entry was posted in GNU/Linux, Python and tagged , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s