05 January 2021, 09:46 | #1 |
Registered User
Join Date: Jun 2020
Location: Scotland
Posts: 146
|
ReadArgs and wildcard expansion
Hi,
Just getting back into Amiga Programming and C on my A1200/3.1.4 after almost 30 years. I have a question for more experienced hands though. I'm working on a super minimal native git implementation, just enough to be able to add some files, commit and push/pull to GitHub for now, to make it easier to work across my Mac and Amiga with VBCC. As I go through the many rounds of Yak shaving just figuring out *how* things work, I've hit what seemed a weird one. Code:
git_add #?.c Code:
FILES/M/A Code:
ReadArgs Code:
#?.c Code:
GetCurrentDir I noticed that, e.g. Code:
type #?.txt So... either someone has to write all that code to walk the directory and PatternMatch the strings in every single tool, again and again, or there's some trick I'm missing either in the CLI or in the code to make this work the way I expect. Any help or suggestions (or the source code for the TYPE command :-) welcomed. Alan |
05 January 2021, 10:59 | #2 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
Only a Unix shell automatically expands such patterns, before passing them to the application. |
|
05 January 2021, 11:18 | #3 |
Registered User
Join Date: Jun 2020
Location: Scotland
Posts: 146
|
@phx. Damn. I was afraid of that. :-) Thanks.
I might try and make the code into a little reusable library cause I'll need it for some other git commands. I was spoiled by Ruby's Dir.glob |
05 January 2021, 12:34 | #4 |
Registered User
Join Date: Jun 2020
Location: Scotland
Posts: 146
|
Aha, I just reread and I didn't know about AnchorPath/MatchXXX so that's actually much easier than I was thinking with Examine and recursing and pattern matching each string myself. :lightbulb: Thanks again @phx.
|
06 January 2021, 15:55 | #5 | |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 680
|
Quote:
you might also consider Code:
int scandir(const char *dirname,struct dirent ***namelist, int (*select)(const struct dirent *), int (*dcomp)(const struct dirent **, const struct dirent **)) which is provided by libnix PS: I hope it's working^^ Last edited by bebbo; 06 January 2021 at 16:27. Reason: PS |
|
06 February 2021, 16:49 | #6 |
Registered User
Join Date: Jun 2020
Location: Scotland
Posts: 146
|
Thanks @bebbo, I am trying as best I can to not rely on anything other than standard amiga APIs because I am a masochist. :-)
|
12 March 2021, 17:46 | #7 |
Registered User
Join Date: Mar 2020
Location: Boulder Creek / USA
Posts: 43
|
Not completely related to your post, but I have a small personal wiki usually used for my own purposes but did a RDArgs post you might find interesting. It’s just a way of using it that doesn’t rely on setting #defines for variable storage index markers.
Would be curious what you think. Or any pointers you might have. https://nyteshade.com:3443/amiga-rdargs Sent from my iPhone using Tapatalk |
12 March 2021, 18:45 | #8 | |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 6,985
|
Quote:
You do not need to allocate a RDArgs structure if you want to read args from the command line, you can supply a NULL pointer to ReadArgs. A pre-allocated RDArgs is only needed if you want to parse a string in memory. It does not make much sense to create a memory pool if you allocate only one chunk of memory. And of course the arguments array can be held on the stack, you do not need to allocate it. |
|
12 March 2021, 19:05 | #9 |
Registered User
Join Date: Mar 2020
Location: Boulder Creek / USA
Posts: 43
|
Thanks for the feedback. I was going to do an extra piece on the extra help portion as well to indicate how you can print out additional usage info if you supply a second ? to template string prompt in the shell.
You’re right that the pool of memory is wasteful here; it’s a habit of mine to play with pools of late. Sent from my iPhone using Tapatalk |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
ReadARgs() bug in Roadshow AddNetInterface | Bruce Abbott | Coders. System | 11 | 21 September 2023 04:06 |
ReadArgs implementation for kickstart 1.3 | jotd | Coders. Asm / Hardware | 19 | 06 February 2023 12:45 |
Query about "all" wildcard in Shell | Foebane | support.Apps | 6 | 05 January 2020 14:08 |
Help please strugglng to get multiple options out of ReadArgs | chocsplease | Coders. C/C++ | 28 | 23 July 2017 19:07 |
Using ReadArgs() from asm | oRBIT | Coders. General | 4 | 11 May 2010 16:11 |
|
|