Skip to content

Commit 4860bd3

Browse files
committed
Only bracket if necessary in showPerms
1 parent 6b05543 commit 4860bd3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Node/FS/Perms.purs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import Global (readInt)
1616
import Data.Array () -- for Semigroup and Functor instances
1717
import Data.Maybe (Maybe(..))
1818
import Data.Char (Char(), charString, fromCharCode)
19-
import Data.String (toCharArray, joinWith, drop, charAt)
19+
import Data.String (toCharArray, joinWith, drop, charAt, indexOf)
2020
import Data.Int (Int(), fromNumber, toNumber)
2121

2222
-- | A `Perm` value specifies what is allowed to be done with a particular
@@ -94,7 +94,10 @@ instance showPerms :: Show Perms where
9494
show (Perms { u = u, g = g, o = o }) =
9595
"mkPerms " <> joinWith " " (f <$> [u, g, o])
9696
where
97-
f perm = "(" <> show perm <> ")"
97+
f perm = let str = show perm
98+
in if indexOf " " str == -1
99+
then str
100+
else "(" <> str <> ")"
98101

99102
-- | Attempt to parse a `Perms` value from a `String` containing an octal
100103
-- | integer. For example,

0 commit comments

Comments
 (0)