@@ -27,10 +27,11 @@ use anyhow::{anyhow, Result};
27
27
use clap:: { Parser , Subcommand } ;
28
28
use directories:: UserDirs ;
29
29
use fehler:: { throw, throws} ;
30
- use home_dir:: HomeDirExt ;
30
+ // use home_dir::HomeDirExt;
31
31
use itertools:: Itertools ;
32
32
use rand:: distributions:: Alphanumeric ;
33
33
use rand:: { thread_rng, Rng } ;
34
+ //use shellexpand::full;
34
35
use shlex:: Shlex ;
35
36
use std:: {
36
37
env,
@@ -688,15 +689,18 @@ impl Session {
688
689
if line. contains ( "new-window" ) {
689
690
tmwin += 1 ;
690
691
}
691
- let modline = line
692
- . replace ( "SESSION" , & self . sesname )
693
- . replace ( "$HOME" , "~/" )
694
- . replace ( "${HOME}" , "~/" )
695
- . replace ( "TMWIN" , & tmwin. to_string ( ) )
696
- . expand_home ( ) ?
697
- . into_os_string ( )
698
- . into_string ( )
699
- . expect ( "String convert failed" ) ;
692
+ let modline = shellexpand:: full (
693
+ & line
694
+ . replace ( "SESSION" , & self . sesname )
695
+ . replace ( "$HOME" , "~/" )
696
+ . replace ( "${HOME}" , "~/" )
697
+ . replace ( "TMWIN" , & tmwin. to_string ( ) ) ,
698
+ ) ?
699
+ . to_string ( ) ;
700
+ // .expand_home()?
701
+ // .into_os_string()
702
+ // .into_string()
703
+ // .expect("String convert failed");
700
704
self . targets . push ( modline) ;
701
705
}
702
706
}
@@ -1189,26 +1193,19 @@ fn parse_line(line: &str, replace: &Option<String>, current_dir: &Path) -> Resul
1189
1193
// but obviously people may mistype and have a single LIST
1190
1194
// in a line.
1191
1195
// Also, ~ and $HOME/${HOME} expansion are supported.
1192
- let cmd: String = cmdparser
1193
- . next ( )
1194
- . ok_or_else ( || anyhow ! ( "Empty LIST found - no command given" ) ) ?
1195
- . replace ( "$HOME" , "~/" )
1196
- . replace ( "${HOME}" , "~/" )
1197
- . expand_home ( ) ?
1198
- . into_os_string ( )
1199
- . into_string ( )
1200
- . expect ( "String convert failed" ) ;
1196
+ let cmd: String = shellexpand:: full (
1197
+ & cmdparser
1198
+ . next ( )
1199
+ . ok_or_else ( || anyhow ! ( "Empty LIST found - no command given" ) ) ?
1200
+ . replace ( "$HOME" , "~/" )
1201
+ . replace ( "${HOME}" , "~/" ) ,
1202
+ ) ?
1203
+ . to_string ( ) ;
1201
1204
// Next we want the arguments.
1202
1205
// Also, ~ and $HOME/${HOME} expansion are supported.
1203
1206
let args: Vec < String > = cmdparser
1204
1207
. map ( |l| l. replace ( "$HOME" , "~/" ) . replace ( "${HOME}" , "~/" ) )
1205
- . map ( |l| {
1206
- l. expand_home ( )
1207
- . expect ( "Could not successfully expand ~ for arguments of LIST call" )
1208
- . into_os_string ( )
1209
- . into_string ( )
1210
- . expect ( "String convert failed" )
1211
- } )
1208
+ . map ( |l| shellexpand:: full ( & l) . expect ( "Could not expand" ) . to_string ( ) )
1212
1209
. collect ( ) ;
1213
1210
debug ! ( "cmd is {}" , cmd) ;
1214
1211
debug ! ( "args are {:?}" , args) ;
0 commit comments