Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow use of FD higher than 9 #247

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Saruspete
Copy link

@Saruspete Saruspete commented Sep 25, 2021

Hello,

I'm using fds 98/99 to be fairly high and not disturb scripts using my library.
When doing tests with:

UseFD 98
It "Emits a warning if an element is invalid"
    When call ammString::ExpandIntegerList "7-10,11,12,a-f,14-16"
    The fd 98 should include "is not an integer"
    The output should eq "7 8 9 10 11 12 14 15 16 "
End

It gave me errors:

Examples:
  1) string.lib: pattern matching: ammString::Contains returns success if a simple string is contained in another
     1.1) ERROR: UseFD: Invalid file descriptor: 98

I fixed it with a wildcard after the number to avoid ugly repetition of [0-9]|[0-9][0-9]| ... as we can have more than 20 numbers (max_files is an unsigned long in struct files_stat_struct of file linux/include/uapi/linux/fs.h )

Maybe you'll want to use an helper like "isInt" which is something like [[ -n "${1//[0-9]/}" ]] but I'm not sure on how you'll want it used.

Just to know, is a new release planned soon ?

Thanks a lot !
Adrien

@Saruspete Saruspete mentioned this pull request Nov 14, 2021
@sideeffect42
Copy link

POSIX only requires file descriptors 0-9 to be available (cf. https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_07).

Also, [0-9]* in a glob has a different meaning to the same regular expression.
9foo also matches the glob, while the empty string does not match the glob, but matches the regular expression.

Maybe using arithmetic expansions (e.g. $(($2))) is a better idea, but needs special treatment for the integer 0, because all non integers will be expanded to 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants