Questions tagged [positional-parameter]

104 questions
284
votes
7 answers

What is the difference between named and positional parameters in Dart?

Dart supports both named optional parameters and positional optional parameters. What are the differences between the two? Also, how can you tell if an optional parameter was actually specified?
Seth Ladd
  • 112,095
  • 66
  • 196
  • 279
20
votes
3 answers

Assigning to a positional parameter

How can I assign a value to a positional parameter in Bash? I want to assign a value to a default parameter: if [ -z "$4" ]; then 4=$3 fi Indicating that 4 is not a command.
Freeman
  • 5,810
  • 3
  • 47
  • 48
14
votes
1 answer

python SyntaxError: positional argument follows keyword argument

I have a python 3 function which is defined like below: def hidden_markov_model(distribution, K=3, N=100, *args): when i call the function, i get this error: Q_hmm = hidden_markov_model(Gaussian, K=K, N=N, mu,…
Atena
  • 471
  • 1
  • 6
  • 18
8
votes
1 answer

define Julia functions with optional positional arguments

From this link, it says: # You can define functions with optional positional arguments function defaults(a,b,x=5,y=6) return "$a $b and $x $y" end defaults('h','g') # => "h g and 5 6" defaults('h','g','j') # => "h g and j…
lanselibai
  • 1,203
  • 2
  • 19
  • 35
7
votes
1 answer

Positional Parameter error in powershell script

I was trying to install/update EPO agent through PowerShell, but I am getting below error. I am new to PowerShell so I am not able to see what is causing this. Below is the script I used to update the agent : Start-Process -FilePath $scriptpath…
Gopi
  • 619
  • 2
  • 9
  • 27
5
votes
1 answer

How can I get argparse to recognize a positional argument which follows a variable length optional argument?

I am writing a script that will be used to merge several input files, generating a single output file, and I want to build a small command line interface using argparse. To me, the most natural-seeming way to do it would be to have a single…
stachyra
  • 4,423
  • 4
  • 20
  • 34
3
votes
1 answer

How To Set Positional Arguments in Jenkins Groovy

Does Groovy support positional arguments? I have a function defined in a Jenkins shared library name.groovy def call(name, age) { sh """ echo "My name is: ${name}" echo "My age is: ${age}" """ } And when I call it from the pipeline stage ('Shared…
3
votes
1 answer

completion Candidates for positional parameter in picocli

I'm trying to provide completion for positional parameters. Somewhere I found note that they are not very well supported, but currently I'm not able to find exact place in spec and I'm not sure what that really means. In meantime I found…
zimi
  • 1,586
  • 12
  • 27
3
votes
1 answer

"$1" is empty when running bash -c scriptname arg

I was trying to develop a simple bash script where one positional parameter is used. But for no reason the parameter is empty. The bash script is given bellow. #!/bin/bash ulimit -s hard if [ "$1" != "" ]; then echo "Positional parameter 1…
3
votes
3 answers

Python calling out positional argument

I have a python function (python 2.5) with a definition like: def Foo(a, b='Silly', c='Walks', d='Spam', e='Eggs', f='Ni', *addl): Where addl can be any number of strings (filenames) to do something with. I'm fine with all of the defaults, but I…
2
votes
1 answer

Function Parameter Position suddenly acting weird

Code: This example illustrates what I mean: Function test{ param( [parameter(Position = 0, ValueFromPipeline)] [string]$Param0, [parameter(Position = 1)] [ArgumentCompletions("Param1_Opt1", "Param1_Opt2")] [Array]$Param1 =…
2
votes
1 answer

How to replace each delimiter in an arbitrary number of command-line arguments that are all delimited name-value pairs?

How to change a command line argument in Bash? explains how to modify input arguments in bash. But in my case, I have a dynamic set of input arguments. I don't know how many are there. This is my command: send url key1=value1 key2=value2…
2
votes
1 answer

How to make argparse treat all arguments as positional?

How can I make an argparse parser treat all arguments as positional, even the ones that look like options? For example, with this definition: parser.add_argument('cmd', nargs='*', help='The command to run') I want to be able to run prog.py mycomand…
planetp
  • 14,248
  • 20
  • 86
  • 160
2
votes
1 answer

How to pass positional arguments to an interactive bash session

I wanted to start an interactive bash shell like this : bash (...some options) 1 2 3 so that in the shell session, I have $1=1, ... I didn't find any options to achieve the effect. I tried this, thought it might work : bash -c bash _ 1 2 3 but it…
Philippe
  • 20,025
  • 2
  • 23
  • 32
1
2 3 4 5 6 7