Skip to content

Commit

Permalink
fix(pwsh): do not check for write permissions
Browse files Browse the repository at this point in the history
as this permission is already present, it does not set executable
permissions when needed rsulting is a crashing command

resolves #393
  • Loading branch information
JanDeDobbeleer committed Feb 11, 2021
1 parent b830ae6 commit 9db255e
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/powershell/oh-my-posh/oh-my-posh.psm1
Expand Up @@ -32,17 +32,15 @@ function Set-ExecutablePermissions {
$permissions = ((ls -l $executable) -split ' ')[0] # $permissions will be something like '-rw-r--r--'
if ((id -u) -eq 0) {
# Running as root, give global executable permissions if needed
$hasWrite = $permissions[2] -eq 'w'
$hasExecutable = $permissions[3] -eq 'x'
if ($hasWrite -and -not $hasExecutable) {
if (-not $hasExecutable) {
Invoke-Expression -Command "chmod g+x $executable"
}
return
}
# Running as user, give user executable permissions if needed
$hasWrite = $permissions[8] -eq 'w'
$hasExecutable = $permissions[9] -eq 'x'
if ($hasWrite -and -not $hasExecutable) {
if (-not $hasExecutable) {
Invoke-Expression -Command "chmod +x $executable"
}
}
Expand Down

0 comments on commit 9db255e

Please sign in to comment.