diff options
author | B. Watson <urchlay@slackware.uk> | 2024-04-09 15:34:12 -0400 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2024-04-09 15:35:05 -0400 |
commit | 8b52215d6dba5eb97712d872520f2bccc34aa630 (patch) | |
tree | 4f83f0c36e0a1133352f89b1dbcfdfd41962b9c3 | |
parent | 6ae3915c0f16d906cb57248fa52f886cbd9a25c6 (diff) | |
download | misc-scripts-8b52215d6dba5eb97712d872520f2bccc34aa630.tar.gz |
soxdial: support GNU --option=value and options with no space before their args.
-rwxr-xr-x | soxdial | 38 |
1 files changed, 30 insertions, 8 deletions
@@ -40,11 +40,11 @@ option. =head1 OPTIONS -Note that option bundling is not supported. Use e.g. B<-v -n>, not B<-vn>. Also, -spaces are required between options and their arguments. Use e.g. B<-b 16>, -not B<-b16>. - -Also, GNU style --option=value is not supported (use B<--bits 16>, not B<--bits=16>). +Note that option bundling is not supported. Use e.g. B<-v -n>, +not B<-vn>. Spaces are allowed but not required between options and +their arguments: B<-b16> and B<-b 16> are equivalent. Also, GNU-style +B<--option=value> is supported (and works the same as B<--option +value>). =head2 Global Options @@ -455,13 +455,35 @@ if(!@ARGV) { exit 1; } +# preprocess @ARGV, convert e.g. -b16 to -b 16, --foo=bar to --foo bar. +@newargv = (); +for(@ARGV) { + if(/^(--?\w+)=(\S+)$/) { + push @newargv, $1, $2; + } elsif(/^(--?[blcdts])(\d+(?:ms)?)/i) { + push @newargv, $1, $2; + } elsif(/^(--?[r])(\d+(?:k)?)/i) { + push @newargv, $1, $2; + } elsif(/^(--?[D])(\w\w)/i) { + push @newargv, $1, $2; + } elsif(/^(--?o)(\S+)/) { + if($2 eq 'utput') { + push @newargv, $_; + } else { + push @newargv, $1, $2; + } + } else { + push @newargv, $_; + } +} + +@ARGV = @newargv; + # this is a big ugly mess. should be refactored. works, though. for ($argc = 0; $argc < @ARGV; $argc++) { $_ = $ARGV[$argc]; - if(/=/) { - die "$SELF: GNU-style --option=value not supported, use --option value.\n"; - } elsif(/--?(?:V|version)$/) { + if(/--?(?:V|version)$/) { print "$SELF $VERSION\n"; exit 0; } elsif(/^--?man$/) { |