qemu-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: #!shebang


From: lacsaP Patatetom
Subject: Re: #!shebang
Date: Wed, 20 Nov 2024 10:48:27 +0100

Le mer. 20 nov. 2024 à 10:37, lacsaP Patatetom <patatetom@gmail.com> a écrit :
hi,

I'd like to use an executable file as a configuration file for `qemu` using a shebang : let me explain.

I currently store my configuration like this in `configuration.qemu` :
```
-argument

- argument -option

-etc...
```

and I call `qemu` like this and it works as expected :
`$ qemu $(<configuration.qemu)`

which corresponds to the following command line :
`$ qemu -argument -argument -option -etc...`

I can also add additional/temporary arguments/options on the command line if I wish.

I'd like to add comments to this configuration file :
```
# this is a configuration file for...

-argument

# this option...
-argument -option

# add your own arguments/options here...
-etc...
```

but passed directly in this way, these comments become arguments/options for `qemu` :
```
$ qemu $(<configuration.qemu)
qemu-system-x86_64: # this is a configuration file for...: Could not open '# this is a configuration file for...': No such file or directory
```

I can eliminate them using `grep` like this :
`$ qemu $(grep -v '^#' configuration.qemu)`

but it seems to me complicated and time-consuming to enter.

so I wanted to use `grep` as shebang :
```
#!/usr/bin/grep -v '^#'
# this is a configuration file for...

-argument

# this option...
-argument -option

# add your own arguments/options here...
-etc...
```

but it doesn't work as I'd hoped :
```
$ qemu $(./configuration.qemu)
/usr/bin/grep: invalid option -- ' '
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.
```

does anyone have an explanation or another way to get a commented configuration file ?

regards, lacsaP.

`#!/usr/bin/env -S grep -v '^#'` as shebang works like a charm :-)
 (with env (GNU coreutils) 9.5)

regards, lascaP.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]