11import { splitShellArgs } from "../utils/shell-argv.js" ;
22import { normalizeExecutableToken } from "./exec-wrapper-tokens.js" ;
3+ import { parseInlineOptionToken } from "./inline-option-token.js" ;
34
45export const COMMAND_CARRIER_EXECUTABLES = new Set ( [ "sudo" , "doas" , "env" , "command" , "builtin" ] ) ;
56
@@ -97,7 +98,7 @@ export function isEnvAssignmentToken(token: string): boolean {
9798}
9899
99100function optionName ( token : string ) : string {
100- return token . split ( "=" , 1 ) [ 0 ] ?? token ;
101+ return parseInlineOptionToken ( token ) . name ;
101102}
102103
103104type ParsedCarrierOption = {
@@ -113,20 +114,21 @@ function parseCarrierOptionToken(
113114 nonExecutingOptions : ReadonlySet < string > = new Set ( ) ,
114115) : ParsedCarrierOption [ ] | null {
115116 if ( token . startsWith ( "--" ) ) {
116- const name = optionName ( token ) ;
117+ const option = parseInlineOptionToken ( token ) ;
118+ const name = option . name ;
117119 if (
118120 standaloneOptions . has ( name ) ||
119121 optionsWithValue . has ( name ) ||
120122 nonExecutingOptions . has ( name )
121123 ) {
122- const valueDelimiter = token . indexOf ( "=" ) ;
123- return [
124- {
125- name ,
126- hasInlineValue : valueDelimiter >= 0 ,
127- inlineValue : valueDelimiter >= 0 ? token . slice ( valueDelimiter + 1 ) : undefined ,
128- } ,
129- ] ;
124+ const parsedOption : ParsedCarrierOption = {
125+ name ,
126+ hasInlineValue : option . hasInlineValue ,
127+ } ;
128+ if ( option . hasInlineValue ) {
129+ parsedOption . inlineValue = option . inlineValue ;
130+ }
131+ return [ parsedOption ] ;
130132 }
131133 return null ;
132134 }
0 commit comments