-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
I already opened a similar issue, then I did not receive a reasonable answer, I decided to wait until the new release, but nothing has changed.
If you use the table format, then trailing zeros are added to the non-integer numeric value:
[pscustomobject] @{ dollar = 1.95; monat = 20.01 }
dollar monat
------ -----
1,950 20,010If I cast these values to a string type, then I will have to format the alignment in the columns of the table:
[pscustomobject] @{ dollar = 1.95; monat = 20.01 }
| Format-Table @{lab='dollar'; exp={$_.dollar.ToString()}; a='right'},
@{lab='monat'; exp={$_.monat.ToString()}; a='right'}
dollar monat
------ -----
1,95 20,01or
[pscustomobject] @{ dollar = [string] 1.95; monat = [string] 20.01 }
| Format-Table @{lab='dollar'; exp={$_.dollar}; a='right'},
@{lab='monat'; exp={$_.monat}; a='right'}Or get this object as a list.
But the situation is such that the script outputs an object with more than thirty values and six properties.
Thus, the complete list will be 30 * 6 + 30 separators = 210 lines. The only possible option is a table.
But I will not format the output of the script directly in the console.
The variant with alignment right during the formation of the object is also not suitable, because there will be indents when viewed as a list.
[pscustomobject] @{ dollar = '{0,6}' -f 1.95; monat = '{0,5}' -f 20.01; weather = 'clear' }
| Format-List
dollar : 1,95
monat : 20,01
weather : clearAdvise what to do, in Windows it is tolerable, there is only one zero added, up to hundredths, and in Linux two zeros, up to thousandths.
Expected behavior
Table view of PsCustomObject should not add trailing zeroes, should return value of non-integer numeric as is.Actual behavior
PSCustomObject adds trailing zeroes to table format.Error details
No ErrorsEnvironment data
Name Value
---- -----
PSVersion 7.4.0-preview.1
PSEdition Core
GitCommitId 7.4.0-preview.1
OS Linux 6.1.9-arch1-1 #1 SMP PREEMPT_DYNAMIC Wed, 01 Feb 2023 17:07:39 +0000
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Visuals
Horror