Comments (3)
That's definitely how I prefer to see it handled:
- Wrap on pipe (if the line's long enough to wrap)
- Indent if you wrap on pipeline.
I guess I'm used to Python and Yaml, but I do not worry about the lack of the closing line.
I would not use parenthesis to try and show the end of a block, if only because they have side effects. This, for example, would result in outputting $Moved
.
($Moved = Get-ChildItem $SourceFolder |
Where Length -gt 100mb |
Move-Item -Destination $TargetFolder -Passthru
)
from powershellpracticeandstyle.
But it's more than that. Parentheses are also blocking. Compare:
1..100 |
ForEach { start-sleep -m 100; $_ }
(1..100 |
ForEach { start-sleep -m 100; $_ }
)
from powershellpracticeandstyle.
Thanks @Jaykul
Agreed; an assignment within brackets has side effects / for that (if adopting the brackets approach) I'd place the bracket after the equals sign:
$Moved = (
Get-ChildItem $SourceFolder |
Where Length -gt 100mb |
Move-Item -Destination $TargetFolder -Passthru
)
... but you're right that the approach of using brackets may lead to people placing the bracket before the assignment and being caught out.
from powershellpracticeandstyle.
Related Issues (20)
- Question: Best Practice fot HOT 3
- Indentation advice is bad/wrong HOT 9
- Constant variables placement with in a script. HOT 1
- Is it better to use $PSItem vs $error[0] or $_ HOT 2
- Add Set-Variable vs. $foo = "bar" best practice HOT 2
- Correct formatting HOT 5
- Unquoted strings HOT 3
- Indentation on Comment-Based help HOT 5
- Consider revising PERF-02 HOT 1
- Naming-Conventions refers to a broken link
- Guidance on External Module Dependencies HOT 3
- Suggestion - explain why the second command in PERF-01 is faster
- Capitalization of function parameter type HOT 2
- Broken link and sentence fragment on naming conventions page
- Module structure HOT 4
- Avoid Using Semicolons (`;`). HOT 3
- Parameter Comments and Get-Help HOT 2
- Begin/Process/End or Process only. No Process/End, Begin/End, Begin/Process. HOT 5
- How to deal with a module that contains multiple interdependent classes? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from powershellpracticeandstyle.