Skip to content

Commit

Permalink
base/machine_posix: fallback to USERNAME for m_getlog
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-zero committed Dec 6, 2018
1 parent d4f120e commit 9eb4201
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/base/machine_posix.f90
Original file line number Diff line number Diff line change
Expand Up @@ -380,17 +380,20 @@ END SUBROUTINE m_chdir
!> \param user ...
! **************************************************************************************************
SUBROUTINE m_getlog(user)
CHARACTER(len=*), INTENT(OUT) :: user
INTEGER :: status
CHARACTER(len=*), INTENT(OUT) :: user
INTEGER :: status

! on a posix system LOGNAME should be defined
CALL get_environment_variable("LOGNAME", value=user, status=status)
! nope, check alternative
IF (status/=0) &
CALL get_environment_variable("USER", value=user, status=status)
! nope, check alternative
IF (status/=0) &
CALL get_environment_variable("USERNAME", value=user, status=status)
! fall back
IF (status/=0) &
user="root ;-)"
user="<unknown>"

END SUBROUTINE m_getlog

Expand Down

0 comments on commit 9eb4201

Please sign in to comment.