gavinhoward/bc

Does not load multiple .bc files using * wildcard

Closed this issue · 3 comments

Hi!
I am trying to load multiple .bc files stored in the same directory as the program (from your modified function files from Carl's collection) but bc will not load them.

The command I give is:
bc -l *.bc

The error I get is:

Fatal error: cannot open file: *.bc
    0: (main)

Loading files separately works, e.g. bc -l file1.bc file2.bc
Loading files using wildcards works in the gnu bc, and it is practical.

I am using the windows 10 terminal.

Hello.

I am actually really surprised that GNU bc will load the files in the Windows 10 terminal, and that is because, as far as I know, wildcard expansion is done by the shell, not the program. So GNU bc doesn't actually do it, or so I thought.

If you were to run my bc with that command under bash on Linux, it would work fine because bash would expand the wildcard into a list of file names and pass that to my bc. It seems the Windows 10 terminal does not do that, but passes the wildcard to my bc, which does not know how to expand it.

Unfortunately, wildcard expansion is a heavy feature, not one I can implement in an afternoon. I think it is out of scope for my bc, and I don't plan on implementing it.

There might be some way to get the Windows 10 terminal to do wildcard expansion, but if that doesn't work, you can run my bc under bash using the Windows Subsystem for Linux.

Thanks a lot for the detailed answer Gavin! It seems like the solution is simple and does not need any change in code. You only need to change the linker used during compiling, like this:

cl example.c /link setargv.obj

Can you try it please? 🙂

Source: https://learn.microsoft.com/en-us/cpp/c-language/expanding-wildcard-arguments?view=msvc-170

I tried adding setargv.obj to the linker command (next to bcrypt.lib), and that didn't work.

If you can get it working, feel free to send me a PR, and I will probably accept it.