shell: fix only to access when shell is not NULL