Skip to content

Set-content does not interpret the psdrive path correctly when the file does not exist #2206

Closed

Description

@bingbing8

Steps to reproduce

1. md /home/yanbing/test                   
2. New-PSDrive -name TESTDRIVE -ROOT /home/bingbing/test -PSProvider FileSystem                                                                    

Name           Used (GB)     Free (GB) Provider      Root                                CurrentLocati
                                                                                                   on
----           ---------     --------- --------      ----                                -------------
TESTDRIVE          13.16        109.75 FileSystem    /home/bingbing/test                              


'abc' | Set-Content -NoNewline -Path TESTDRIVE:/testfile.txt                                                                                 
Set-Content : Could not find a part of the path 
'/home/yanbing/test/home/yanbing/test/home/yanbing/test/testfile.txt'.
At line:1 char:12
+ 'abc' | Set-Content -NoNewline -Path TESTDRIVE:testfile.txt
+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   + CategoryInfo          : ObjectNotFound: (/home/yanbing/t...st/testfile.txt:String) [Set-Content 
  ], DirectoryNotFoundException
   + FullyQualifiedErrorId : GetContentWriterDirectoryNotFoundError,Microsoft.PowerShell.Commands.SetContentCommand

Expected behavior

Should create a file and set the content

Actual behavior

the path got appended three times so can not be found on the system.
If the file already exist, the content can be set to the right file.

Environment data

Name                           Value                                                                  
----                           -----                                                                  
PSVersion                      6.0.0-alpha                                                            
PSEdition                      Core                                                                   
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                
BuildVersion                   3.0.0.0                                                                
GitCommitId                    v6.0.0-alpha.8                                                         
CLRVersion                                                                                            
WSManStackVersion              3.0                                                                    
PSRemotingProtocolVersion      2.3                                                                    
SerializationVersion           1.1.0.1    

Activity

  1. changed the title [-]on Iimunx Set-content does not interpret the psdrive path correctly when the file does not exist[/-] [+]Set-content does not interpret the psdrive path correctly when the file does not exist[/+] on Sep 8, 2016
  2. vors commented on Sep 8, 2016

    @vors
    Collaborator

    Confirmed on OS X.

    Yanbing (@bingbing8) I updated the issue text to use proper formatting. Please, use markdown for issues. For details, see this comment #2144 (comment)

  3. charub commented on Oct 5, 2016

    @charub
    Contributor

    Issue repro's on PowerShell Core on Windows as well. More Info :

    Name Value


    PSRemotingProtocolVersion 2.3
    CLRVersion
    WSManStackVersion 3.0
    SerializationVersion 1.1.0.1
    BuildVersion 3.0.0.0
    PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
    PSEdition Core
    PSVersion 6.0.0-alpha
    GitCommitId v6.0.0-alpha.10

  4. daxian-dbw commented on Nov 1, 2016

    @daxian-dbw
    Member

    Resolved by PR #2392

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Issue-BugIssue has been identified as a bug in the productOS-LinuxOS-macOSWG-Cmdletsgeneral cmdlet issues

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions