The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Susan Harkins (424) [Avatar] Offline
#1
Please post errors you find in the published version of Windows PowerShell in Action, Third Edition. If necessary, we'll publish a comprehensive list for everyone's convenience.

Thank you,
Susan Harkins
Errata Editor
460916 (7) [Avatar] Offline
#2
In print edition under "Book forum" - web page shows "not found" when not logged in. Print page should note the need to log into "Manning" before using the URL. Manning should send web page to logon page when not logged in.

460916 (7) [Avatar] Offline
#3
"Preface"

Reference to "The C Programming Language" should read "The C++ Programming Language". The current reference is for Kernighan & Richie's earlier book.

Rhywun (27) [Avatar] Offline
#4
p. 54

The AppDomain class isn’t available in .NET core which means this technique can’t be used on Linux or Mac machines running PowerShell v6.


This technique is working on MacOS, at least with version 6.0.0-beta.8.
Rhywun (27) [Avatar] Offline
#5
p. 57

In almost all modern languages, strings are immutable. The biggest exception to this we’re aware of is Apple’s new language Swift.


This is not quite accurate. Swift strings, like all Swift types, are immutable when declared with let as opposed to var.
460916 (7) [Avatar] Offline
#6
Rhywun wrote:p. 57

In almost all modern languages, strings are immutable. The biggest exception to this we’re aware of is Apple’s new language Swift.


This is not quite accurate. Swift strings, like all Swift types, are immutable when declared with let as opposed to var.


Not really true. Strings in C# are both. @"string string" is immutable. "string {0} string {1}" is not immutable.

I think you may be thinking that a string cannot be changed without reallocating the string in memory. In Windows and other systems we can use StringBuilder to create strings on he heap that are changeable.

Since the first systems started providing changeable strings most other languages have been extended to also have this feature.
460916 (7) [Avatar] Offline
#7
For a good Net/PowerShell discussion on the immutability of strings in PowerShell see the following discussion:

https://blogs.msdn.microsoft.com/besidethepoint/2010/09/21/decrypt-secure-strings-in-powershell/

521929 (5) [Avatar] Offline
#8
On p. 75, the second paragraph says, "If you wanted to see those numbers in hex…". "Those numbers" refer to the line just previous, which displays the integer for every character in 'Hello world'.

However, the code following the sentence only works for a single character, not for "those numbers". IOW, while
[int[]] [char[]] 'Hello world'

will show a list of integers,
"0x{0:x}" -f [int] [char] 'a'

will only work for a single character; trying to do something like
"0x{0:x}" -f [int[]] [char[]] 'Hello world'

yields only
0xSystem.Int32[]


A couple of questions:
1. I understand why the format only works for a single entry, since the format string has to include the index. However, why don't we get back one hex string instead of the 0xSystem.Int32[]?
2. How would we get hex strings of all the characters in 'Hello world'? IOW, what's the equivalent of
[int[]] [char[]] 'Hello world'

that returns hex for each of the characters?
460916 (7) [Avatar] Offline
#9
Your question is not about "errata" but is a question about how to use PowerShell. Use your search engine to find many examples of hexifying" a sting

OR

'Hello World' | Format-Hex
521929 (5) [Avatar] Offline
#10
You need to re-read my post; it is about errata. The book says "if you wanted to format those numbers" and does not show how to format those numbers. It only shows how to format a single number. So either the book needs to show how to format "those numbers", or it should not refer to "those numbers" at all and only say how to format a specific number.

My additional question only asked how to do what the book said it was doing, which was how to format "those numbers." IOW, since the book didn't do what it said it was going to do, I asked how to do what it said it was going to do. Feel free to ignore that question if you choose, but the errata stands.

(The book shows how to format a single hex character, so I don't need that question answered. And Format-Hex, which I am already familiar with, does not do the same thing as the integer example in the book. The integer version of the answer, in the first paragraph, returns
72
101
108
108
111
32
119
111
114
108
100

The proper answer to "see those numbers in hex" would be the above list, but with 0x hex strings instead of integers.)
460916 (7) [Avatar] Offline
#11
[int[]]('Hello world').ToCharArray() | %{'0x{0:X}' -f $_}
521929 (5) [Avatar] Offline
#12
Excellent, thanks for the hint. In keeping with what the book is doing in this section, with each step building on the previous step, I think the example in the book should look like this:

[int[]] [char[]] 'Hello world' | %{'0x{0:X}' -f $_}
0x48
0x65
0x6C
0x6C
0x6F
0x20
0x77
0x6F
0x72
0x6C
0x64


To summarize, the errata is that since the book says "those numbers" in the fourth example of 2.6.1 on p.75, referring to the previous list of numbers generated from 'Hello world', the above is what the book should contain, not the existing example for a single character. If it only wants to show how to hex a single number, than the example should be before the 'Hello world' example, and should refer back to "that number".
460916 (7) [Avatar] Offline
#13
Yes. That might be more helpful. Apparently the proofreaders didn't test all of the code. Not abnormal for a large book but often very annoying.


Hiroki Murayama (1) [Avatar] Offline
#14
Here's the list of (possible) errors I found during the read. My list is little bit long, so I created a separate document for it.
446156 (1) [Avatar] Offline
#15
Susan Harkins wrote:Please post errors you find in the published version of Windows PowerShell in Action, Third Edition. If necessary, we'll publish a comprehensive list for everyone's convenience.

Thank you,
Susan Harkins
Errata Editor


Chapter 19: Section 19.1.3

Example of enums shows like this in the e-book:

PS> [flags()] enum mybitfield {one = 0x1; two = 0x2; three = 0x4; all = 0x7}


and the text says that the member "all" contains Bitwise AND of all member values. However, it is Bitwise OR and Bitwise AND.

Same way it doesn't explain that it is a Bitwise OR happening in the following text and not bitwise AND

PS> [int] [mybitfield] "one,three"
5
PS> [int] [mybitfield] "one,two,three"
7
PS> [int] [mybitfield] "all"
7