Into{ from {} } vs from{ into {} }


(Steve Cohen) #1

I had a minor issue the other day when I told someone to create a copy spec like this:

			from ('conf') {
				fileMode defaultFileMode
				into ('/path/to/conf') 
                        }

instead of

		into ('/path/to/conf') {
			from ('conf') {
				fileMode defaultFileMode
			}
		}

This was my bad, of course, and I spent a little while scratching my head as to why my file was going to the root directory and ignoring my ‘into’ spec. Eventually I remembered that info was supposed to surround from and not the other way around, and that I could add a nested info block inside the from closure that would be a relative path from the outer info. I realized that the bare from{} not inside an info closure was defaulting to

into ('/')

I got to thinking about this and I thought, who would ever want that default behavior? This was after running the script with --debug logging and not learning anything interesting there.

It occurred to me that there probably isn’t any valid use case for the bare top-level from, since anyone wanting that behavior could easily do

into ('/') {
     from('wherever')  
}

Well, I know you must have backward compatibility issues, but it occurs to me that it would be good to emit a warning message when a bare from{} spec is encountered, or at least a debug message. More than likely, a copy to root directory is not what the script writer desired.