Skip to content

[Windows][IM] Multiline --text is truncated via npm .cmd shim, with no stdin/file fallback #1989

Description

@yingsongbei

Environment

  • Windows PowerShell 5.1
  • @larksuite/cli v1.0.73
  • Installed globally through npm
  • Command: im +messages-send

Problem

When multiline text is passed through the npm-generated lark-cli.cmd wrapper, only the content before the first newline reaches the CLI.

$msg = "line 1`nline 2`nline 3"

& "$env:APPDATA\npm\lark-cli.cmd" `
  im +messages-send `
  --as user `
  --chat-id oc_dryrun_test `
  --dry-run `
  --format json `
  --text $msg

The dry-run request contains only:

{"text":"line 1"}

There is also a safety concern: if --dry-run is placed after the multiline argument, the newline may truncate that flag as well, causing the CLI to attempt a real API request.

The npm-generated lark-cli.ps1 entry preserves all lines, but embedded double quotes are removed under Windows PowerShell 5.1.

$msg = "line 1`nline 2`nreply `"confirm`""

The resulting text preserves the lines but becomes:

line 1
line 2
reply confirm

I also tested possible shell-safe fallbacks:

  • --text - sends the literal -; stdin is not read.
  • --text @message.txt sends the literal @message.txt; file input is not supported.

Expected behavior

im +messages-send --text should preserve all line breaks and embedded quotes, or provide a shell-safe input mechanism on Windows.

Suggested solution

Please consider supporting one or more of:

  • --text-file message.txt
  • --text - for stdin
  • --text @message.txt
  • Equivalent file/stdin support for --markdown and message replies
  • Windows-specific tests and documentation for multiline text

A Node wrapper using an argument array preserves the content correctly, which confirms that the message-processing logic itself can handle the full text.

Metadata

Metadata

Assignees

No one assigned

    Labels

    domain/imPR touches the im domain

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions