Skip to content

Set-Regex: Specify how to know the path which is used to save the file if I do not use the Path parameter  #61

@LaurentDardenne

Description

@LaurentDardenne

The documentation :

    -Path <String>
        The path to the file.  If this is not provided, it will save regular expressions to the user's Irregular
        module path.

1 - When I save a regex I can't tell where the cmdlet is saving the file.

2 - When the module is not installed by Install-module, in this case the behavior concerning the choice of the path is not documented.

Describe the solution you'd like

For 1 : add Verbose parameter.
For 2 : documente the behavior in this case.

Additional context

The Irregular module was not installed by Install-Module (no internet access on the server):

IPMO C: \ Users \ MyAccount \ Downloads \ irregular \ Irregular.psd1

$env:psmodulepath
C:\Users\MyAccount\Documents\WindowsPowerShell\Modules; C:\Program Files\WindowsPowerShell\Modules; C:\Windows\system32\WindowsPowerShell\v1.0\Modules ...

In my case the file is saved in the first path present in $env:psmodulepath :

C:\Users\MyAccount\Documents\WindowsPowerShell\Modules\Irregular\Regex

Found with trace-Command :

Trace-Command PathResolution -expression {
$StartAnchor='\[1'
$EndAnchor ='P]]'
Write-RegEx -Name ExtractDataBetweenMarkers -After ${StartAnchor} -CharacterClass Any  -Greedy -Lazy| 
 write-regex -Before $EndAnchor |Set-Regex } -pshost


#DÉBOGUER : PathResolution Information: 0 :     RESOLVED PATH:
#C:\Users\MyAccount\Documents\WindowsPowerShell\Modules\Irregular\RegEx\ExtractDataBetweenMarkers.regex.txt

The cmdlet create the path '\Irregular\RegEx'

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions