Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 9168b088413424c264ba98bec63ebc85ab4c3e3598a087b373c187c785cf1748
Ticket: efd15d181ae9be3b538eb23534d37d8f1d96cd57
problem with % in [exec] on windows
User & Date: bll on 2020-07-28 01:52:51
Changes

  1. icomment:
    Remember that Tcl will process the double quotes and in this instance you
    want to pass them to the WMIC command.
    
    For example, I have an exec in my program:
    
      set cmd "\"$::sysvars::v(prog.tasklist)\" /fi \"pid eq $ppid\" /nh 2>nul"
      exec -ignorestderr -- {*}$cmd 2>@1
    
    as the quoted string: "pid eq <some-pid>" must be passed to windows with
    the double quotes included.
    
    Examples (these all work):
    
    % close [open "my file" w]
    % exec write "\"my file\""
    % close [open abc%def w]
    % exec write abc%def
    % close [open %abcdef% w]
    % exec write %abcdef%
    %
    
    So try your command with the double quote marks escaped.  This may take
    a little work to figure out.  That's why I like to set the command line
    to execute first, then exec it with exec {*}$cmd.  I can puts $cmd and
    see exactly what will be passed to exec (since it is a list, you have to
    remember that many words will be brace quoted).
    
  2. login: "bll"
  3. mimetype: "text/plain"