@@ -169,8 +169,19 @@ impl<'src> Recipe<'src> {
169169 . contains ( AttributeDiscriminant :: PositionalArguments )
170170 }
171171
172- pub ( crate ) fn change_directory ( & self ) -> bool {
173- !self . attributes . contains ( AttributeDiscriminant :: NoCd )
172+ pub ( crate ) fn change_directory ( & self , settings : & Settings ) -> bool {
173+ if self
174+ . attributes
175+ . contains ( AttributeDiscriminant :: WorkingDirectory )
176+ {
177+ return true ;
178+ }
179+
180+ if self . attributes . contains ( AttributeDiscriminant :: NoCd ) {
181+ return false ;
182+ }
183+
184+ !settings. no_cd
174185 }
175186
176187 fn print_exit_message ( & self , settings : & Settings ) -> bool {
@@ -185,20 +196,20 @@ impl<'src> Recipe<'src> {
185196 }
186197 }
187198
188- fn working_directory < ' a > ( & ' a self , context : & ' a ExecutionContext ) -> Option < PathBuf > {
189- if !self . change_directory ( ) {
190- return None ;
191- }
192-
193- let working_directory = context. working_directory ( ) ;
199+ pub ( crate ) fn working_directory < ' a > ( & ' a self , context : & ' a ExecutionContext ) -> Option < PathBuf > {
200+ let module_working_directory = context. working_directory ( ) ;
194201
195202 for attribute in & self . attributes {
196203 if let Attribute :: WorkingDirectory ( dir) = attribute {
197- return Some ( working_directory . join ( & dir. cooked ) ) ;
204+ return Some ( module_working_directory . join ( & dir. cooked ) ) ;
198205 }
199206 }
200207
201- Some ( working_directory)
208+ if !self . change_directory ( & context. module . settings ) {
209+ return None ;
210+ }
211+
212+ Some ( module_working_directory)
202213 }
203214
204215 fn no_quiet ( & self ) -> bool {
0 commit comments