19 questions
2
votes
1
answer
196
views
Why PowerShell $Matches Hashtable automatic variable is not returning all matches?
I'm using Named Captures in PowerShell. But the following example is not returning all matches. All the lines in the following code return correct output - except the lines 7 and 8. I was expecting $...
1
vote
1
answer
67
views
What does $_ bind to at the top level of pipelines, in Powershell? [duplicate]
In Powershell, a pipeline can contain filters such as ForEach-Object:
get-process | %{$_.name}
Within the script block of the foreach filter, it's possible to use the $_ auto variable to refer to the ...
1
vote
1
answer
165
views
GNUMake - Using text functions with match pattern as prerequisite
I want to use the match pattern of a Makefile rule in a text function in the perquisites list.
Let's say I want to build a file, and that files perquisites are any other files with the same name in a ...
3
votes
1
answer
1k
views
Equivalent of "&& cd $_" in Powershell
With bash I can create a directory and immediately enter it with mkdir mydir && cd $_. Is there a powershell equivalent of $_?
2
votes
1
answer
932
views
What does @$ mean in makefile?
What does @$ mean in the below make recipe ?
@$(OBJCOPY) -S --set-section-flags .bss=alloc,contents -O binary $(BINARY).elf $(BINARY).bin
Thanks
1
vote
3
answers
211
views
Unexpected execution of "all" target in my makefile
I've a makefile that is suppose to repeat an execution of a c code (BootstrapCL.c) one time for each file.csv in the directory. For each execution it should give in input to the c code (as argv) 2 ...
1
vote
1
answer
637
views
How to pass parameters to a PS script invoked through Start-Job?
I want to use start-job to run a .ps1 script requiring a parameter. Here's the script file:
#Test-Job.ps1
Param (
[Parameter(Mandatory=$True)][String]$input
)
$output = "$input to output"
...
0
votes
1
answer
503
views
vpath not picking up newly built objects
I have this Makefile (and GNU Make):
vpath %.o .objs
OBJDIR=.objs
all: symbol_tests.so
symbol_tests.so: symbol_tests.o symbol.o # simulate linking
@echo Linking target: $@, prerequisites: $^
...
5
votes
2
answers
5k
views
Passing arguments as array to PowerShell function
I'm trying to figure out how I can pass multiple strings as an array to a powershell function.
function ArrayCount([string[]] $args) {
Write-Host $args.Count
}
ArrayCount "1" "2" "3"
ArrayCount "...
5
votes
3
answers
4k
views
Why can't I use $_ in write-host?
I am trying to pipe an array of strings to write-host and explicitly use $_ to write those strings:
'foo', 'bar', 'baz' | write-host $_
However, it fails with:
The input object cannot be bound to ...
0
votes
1
answer
1k
views
Powershell equivalent to $_ in bash
In bash, to get argument from last command we call $_.
I have searched but couldn't find what is equivalent to bash's $_ in PowerShell ?
Example:
$ mkdir 20171206
$ cd $_
Now bash current working ...
9
votes
3
answers
16k
views
Functional differences between $PSScriptRoot and $MyInvocation
Problem
I am working with Jenkins to deploy PowerShell scripts remotely. As such, I am trying to figure out if there will be problems utilizing $PSScriptRoot over $MyInvocation.MyCommand.Path for ...
3
votes
1
answer
3k
views
Are global variables in C automatic variables?
I was studying ANSI C programming language and it says in introduction:
"Local variables are typically "automatic," or created anew with each invocation."
I'm guessing allocating and deallocating ...
4
votes
2
answers
4k
views
How does echo $? work?
I am writing some PowerShell scripts to do some build automation. I found here that echo $? returns true or false depending on previous statement. I just found that echo is alias for Write-Output. ...
0
votes
1
answer
275
views
Makefile automatic variables not escaping characters in filenames
I am using automatic variables with static pattern rules in a Makefile, but I have a problem with filenames with parentheses. The parentheses are not escaped properly for the shell, and I get a syntax ...
2
votes
2
answers
608
views
Makefiles: specific 'no input files', automatic variables
I'm new to makefiles, and they puzzle me. I have the following folder hierarchy:
A folder named lib contains tow folders: include (with file mylib.h) and src (with file mylib.cpp). It also contains a ...
1
vote
1
answer
574
views
Target's directory in prerequisites without second expansion
Lets assume, i want to call
make somepath/abc.pot
which depends on somepath/somefiles.c
My target I've created so far looks like
%.pot: $(dir $@)*.c
@echo "it works"
ifeq (,$(wildcard $@))
# ...
1
vote
1
answer
62
views
Can't get different values of dependencies with automatic variable '$<' in makefile
I'm making once which compiles some sort algorithms that i made.
I have a structure like this:
|/sorting_algorithms
|----/bin
|----/build
|----/include
|--------tiempo.h
...
4
votes
2
answers
1k
views
How to invoke a powershell scriptblock with $_ automatic variable
What works -
Lets say I have a scriptblock which I use with Select-Object cmdlet.
$jobTypeSelector = `
{
if ($_.Type -eq "Foo")
{
"Bar"
}
elseif ($_....