box / boxcli

A command line interface for interacting with the Box API.
https://developer.box.com
Apache License 2.0
222 stars 59 forks source link

Name with single/dobule quotation won't work with CLI parameters on Windows Powershell. ex: 'test(1).png' #530

Closed hh259 closed 3 months ago

hh259 commented 3 months ago

I have checked that the SDK documentation doesn't solve my issue.

I have checked that the API documentation doesn't solve my issue.

I have checked that the Box Developer Forums doesn't solve my issue.

I have searched Issues in this repo and my issue isn't already reported.

Describe the bug

Rename using boxcli fails when () is in the name.

Error

PS C:\Program Files\@boxcli\bin> box files:rename fileID 'test(1).png'
.png の使い方が誤っています。 // Translation -> Invalid usage of .png

And need to escape ) with dobule quotation. PS C:\Program Files\@boxcli\bin> box files:rename 1448318961343 'test(1")".png' On PowerShell, () can be renamed as below. PS C:\Users\xxx\Documents> rename-item 'test(1).txt' -newname 'test(2).txt'

Expected behavior

My expectation is to be rename without escaping using double quotation.

Steps to reproduce

Rename file with ) in the name as below: box files:rename fileID 'test(1).png'

Authentication method used in your application

User Authentication (OAuth 2.0)

App Access Level

App + Enterprise Access

What is Box CLI Version and Node used?

@box/cli/3.14.0 win32-x64 node-v14.19.3

What is your Operating System Version?

Windows 11 (Japanese)

arjankowski commented 3 months ago

Hi @hh259,

The issue you encountered is not related to our SDK but to how PowerShell handles strings. In PowerShell, parentheses have a special meaning and are often used for grouping expressions, which leads to the problem you encountered.

To resolve this issue, you can: 1) escape special characters ) using double quotation, like you did:

 box files:rename 1448318961343 'test(1").png'

2) Or, you can use the stop-parsing token --% to stop PowerShell from interpreting input as PowerShell commands or expressions:

box files:rename 1448318961343 --% "test(1).png" 

I recommend using the second option, as it does not interfere with the file name itself.

Let me know if you need any more help!

hh259 commented 3 months ago

Thank you for your comment! It really helps. As rename-item works I thought it is boxcli specific. Thank you so much.