Reputation: 914
I am using a conditional operator but getting the error "extra characters after close-quote". fdx is a parameter I am trying to pass through the function argument and I am checking if the passed argument is "fdx" or not and based on that the value to be written will be decided.
proc set_ifg_seville2 {port sgmii speed fdx} {
case $speed {
10 {
erf_wr -s dev_$port mac_ifg_cfg tx_ifg [expr ($fdx == "fdx") ? 5:4]
}
} #Closing procedure
Upvotes: 0
Views: 626
Reputation: 16428
The expression for the ternary operation in your code should be changed as,
erf_wr -s dev_$port mac_ifg_cfg tx_ifg [expr {$fdx == "fdx" ? 5:4}]
Examples :
% set fdx "fdx"
fdx
% set result [expr {$fdx=="fdx" ? "pass" : "fail" }]
pass
% set result [expr {$fdx=="stackoverflow" ? "pass" : "fail" }]
fail
%
Reference : expr
Upvotes: 3