-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add $# parameter #741
Comments
What would example use cases for this be? Since there is no direct loop support and Nevertheless, I'm interested in trying to add this feature as an intro to bpftrace development. Is making |
Making Positional parameters are optional in bpftrace, and when they are not provided on the command line they get initialised to default values (0 for integers, "" for strings). Two cases that
Scripts at the moment might be checking if a parameter is set by comparing to 0, but this would break if a user passes a value of 0 along through the command line. |
It looks like bpftrace refuses to run scripts that refer to missing positional parameters:
I have a PR more or less ready for |
Missing positional parameters needs to be allowed. Lots of tools will use
it. Optional interval, optional latency threshold, optional pid.
…On Fri, Jun 21, 2019, 8:51 AM Mark Drayton ***@***.***> wrote:
It looks like bpftrace refuses to run scripts that refer to missing
positional parameters:
$ sudo ./src/bpftrace -e 'BEGIN { printf("%d\n", $1) }'
missing positional parameter $1
I have a PR more or less ready for $#. If it's acceptable we could decide
if the missing positional behaviour needs to change.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#741>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAIM3G4QWQRCI6ZZG7FIVS3P3T2GLANCNFSM4HWINWLA>
.
|
Yep sorry, I've just merged #742 which re-enabled optional positional parameters. |
At risk of derailing this PR, it looks like assigning to positionals doesn't work at the moment so setting default values won't work yet:
Maybe |
Ah yeah, I just didn't think through that example well enough. |
To return the number of command line arguments passed to the script at runtime.
The text was updated successfully, but these errors were encountered: